Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git “为什么?”;“cat配置”;在终端中,是否显示在浏览器中创建的回购与使用命令行创建的回购之间的不同配置?_Git_Github_Terminal - Fatal编程技术网

Git “为什么?”;“cat配置”;在终端中,是否显示在浏览器中创建的回购与使用命令行创建的回购之间的不同配置?

Git “为什么?”;“cat配置”;在终端中,是否显示在浏览器中创建的回购与使用命令行创建的回购之间的不同配置?,git,github,terminal,Git,Github,Terminal,当我使用浏览器在GitHub创建存储库测试repo,然后将该存储库克隆到我的机器上时,我在Terminal: [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true [remote "origin"] url = https://gith

当我使用浏览器在GitHub创建存储库测试repo,然后将该存储库克隆到我的机器上时,我在Terminal:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = https://github.com/samuraijane/test-repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = https://github.com/samuraijane/eric-test.git
    fetch = +refs/heads/*:refs/remotes/origin/*
但是当我使用命令行在GitHub创建存储库时

curl -u 'samuraijane' https://api.github.com/user/repos -d  "{\"name\":\"test-repo\"}"
git remote add origin https://github.com/samuraijane/test-repo.git
我在终端中输入
cat config
时看到此数据:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = https://github.com/samuraijane/test-repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = https://github.com/samuraijane/eric-test.git
    fetch = +refs/heads/*:refs/remotes/origin/*

当我使用命令行创建存储库时,
[branch master]
及其相应的数据为什么会丢失?

当您使用浏览器在GitHub上创建存储库时,您还使用浏览器在存储库中创建提交。该提交继续进行,因此创建了
master
分支。克隆存储库时,您将“他们的”(您的)
master
分支作为远程跟踪分支
origin/master
,然后
git clone
能够通过签出本地分支
master
,并将
origin/master
作为其上游


使用
curl
在GitHub上创建存储库时,没有在存储库中创建提交。因此,存储库位于未出生的
master
分支上(名称
master
仅存储在
HEAD
引用中,而不是作为实际分支)。克隆存储库时,没有分支,因此没有远程跟踪分支,
git clone
无法签出本地
master
。因此,克隆中没有分支,
master
(不存在)无法跟踪远程跟踪分支
origin/master
(也不存在)。

非常感谢您提供了这个非常详细的答案。我不熟悉“未出生”一词,因为它与主分支有关。你能提供一个链接或其他资源,让我可以进一步研究这个问题吗?我一直在读,但只读完了第二章。也许在后面的章节中会有这些信息,但如果你能给我指出一些更能解释这一点的东西,那就太好了。谢谢这只是Git用来表示这种状态的一个术语,
HEAD
指向一个分支,即使该分支还不存在。该状态本身的存在是因为
HEAD
始终记录当前分支以及当前提交,但在新存储库中(或使用
git checkout--orphan
创建孤立分支时),该分支不/不能指向任何实际提交。查看google搜索git+unborn+branch的前10个左右的点击率: