Git “为什么?”;“cat配置”;在终端中,是否显示在浏览器中创建的回购与使用命令行创建的回购之间的不同配置?
当我使用浏览器在GitHub创建存储库测试repo,然后将该存储库克隆到我的机器上时,我在Terminal: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
[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个左右的点击率: