git-svn HEAD 与 master 不同

git-svn HEAD differs from master

有时我会进入以下状态,其中 HEAD 不会显示在与 master 相同的提交上。

我想 HEAD 必须被签出并且后续提交必须转到 HEAD。但是如何在同一提交上调整两个指针?

在我看来,您有一个分支 'git-svn',它比 master 提前 1 次提交,而您的 HEAD 就在该提交上。 您可以签出 'git-svn' 分支,然后 push/merge 将其放入 master,如果这是您想要的?

Sometimes I end up in following state, where the HEAD is not to be shown on the same commit as the master.

如上评论所述 - .

回答您的问题:

每次您更改存储库状态时,您的 HEAD 都会被修改并更新并指向当前提交。

detached HEAD 是当 HEAD 指向任何提交 other 而不是最新提交时。

在描述的 link 中,您可以阅读所有相关内容,并且有详细的解释什么是 head,我不会在这里描述。


Can you explain me this?

I changed some file being on HEAD, then I have checkout master and did git svn rebase which failed as there was the file changed.

So I have reverted the changes and did git svn rebase still on master.
The result HEAD, master, git-svn are on the same commit.

I actually did nothing and it is fixed now? How is that?


让我们把它分成几部分,我会解释每一部分:

I changed some file being on HEAD

不能直接在 HEAD 上做任何事情。 HEAD 只是对提交的引用。它是一个简单的文本文件,用于存储当前分支现在指向的提交的 SHA-1。


then I have checkout master

现在您的 HEAD 指向 master 上的最新提交。


... did git svn rebase ... reverted the changes

您的 HEAD 已恢复到变基前的原始值 - 应该不会出现任何更改。 (不要将它与 git revert 命令混淆)


The result HEAD, master, git-svn are on the same commit.
I actually did nothing and it is fixed now? How is that?

如上所述 - 像这样看。您开始散步(在这个比喻中,HEAD 存储您距离开始步行的距离)。你到处走来走去(你试图做的改变),然后你决定不喜欢走路,然后你就回家了。 (你恢复了变基)。现在 HEAD 恢复到原来的值,因为没有提交任何“工作”。