我今天结束了一个分离的头,同样的问题描述:git推送说所有最新的,即使我有局部的变化
据我所知,我没有做任何不同寻常的事情,只是从本地回购中提交和推送。
那么,我是如何得到一个分离的头部的呢?
我今天结束了一个分离的头,同样的问题描述:git推送说所有最新的,即使我有局部的变化
据我所知,我没有做任何不同寻常的事情,只是从本地回购中提交和推送。
那么,我是如何得到一个分离的头部的呢?
当前回答
如果不能使用git开关,使用'git checkout -b [branch]'而不是'git checkout [branch]'
其他回答
分离HEAD意味着当前签出的不是本地分支。
导致分离HEAD状态的一些场景:
If you checkout a remote branch, say origin/master. This is a read-only branch. Thus, when creating a commit from origin/master it will be free-floating, i.e. not connected to any branch. If you checkout a specific tag or commit. When doing a new commit from here, it will again be free-floating, i.e. not connected to any branch. Note that when a branch is checked out, new commits always gets automatically placed at the tip. When you want to go back and checkout a specific commit or tag to start working from there, you could create a new branch originating from that commit and switch to it by git checkout -b new_branch_name. This will prevent the Detached HEAD state as you now have a branch checked out and not a commit.
如果不能使用git开关,使用'git checkout -b [branch]'而不是'git checkout [branch]'
如果您试图通过重新签出文件而撤消所做的更改,并且语法不完全正确,则很容易发生这种情况。
你可以看看git日志的输出——你可以把上次成功提交后的日志尾部粘贴到这里,我们都可以看到你做了什么。或者你可以粘贴它,然后在freenode IRC上的#git中询问。
在我的案例中,情况是这样的:
创建一个新的分支(feb_debugging)。 运行git fetch 我看到新的分支(feb_debugging)被拉 现在,我使用git checkout origin/feb_debugging
在这里它让我到HEAD现在在....
我只需要再结账一次
Git签出feb_debugging 现在git说我在feb_debugging分支。
当你签出到一个commit git checkout <commit-hash>或一个远程分支时,你的HEAD将被分离,并尝试在上面创建一个新的提交。
任何分支或标记都无法访问的提交将在30天后被垃圾收集并从存储库中删除。
解决这个问题的另一种方法是为新创建的提交和签出创建一个新分支。Git checkout -b <branch-name> <commit-hash>
本文将说明如何进入分离HEAD状态。