我不完全确定导致这种情况的步骤,但是我最终没有我的 GIT master 分支。
我很擅长使用此处的说明修复问题:http://sitaramc.github.com/concepts/detached-head.html然而,我对 GIT 的普遍无知可能让我陷入比开始时更糟糕的困境。
$ git branch
first-cucumber-attempt
notifications
* second-cucumber-attempt
sendgrid-setup
在某些时候,我显然开始研究一个分离的 HEAD,现在我不知道如何找到我的主人(我现在感觉有点像爱丽丝)。
尝试 checkout master 给出:
$ git checkout master
error: pathspec 'master' did not match any file(s) known to git.
尝试 pull master 给出:
$ git pull origin master
From github.com:petenixey/kind-advice
* branch master -> FETCH_HEAD
Already up-to-date.
“second_cucumber_attempt”分支包含我想 merge 到 master 中的所有代码,master 在 github 上仍然是安全的,但我无法访问它。我彻底卡住了。
最佳答案
git checkout master
中的“master”应该是一个分支,但你没有。您可以使用 git checkout origin/master -b master
检查 Remote 的 master 并使其成为您自己的,这也应该将其设置为“跟踪分支”。
您可以使用 git branch -r
查看您的远程分支列表。
关于git - 我已经失去了我的主分支和根据 GIT,我的头(虽然我可以告诉它)。我怎样才能让他们回来?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4673168/