git 分支显然有分歧,但提交历史是相同的

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2298556/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 07:53:04  来源:igfitidea点击:

Branches have apparently diverged, but commit history is identical

git

提问by Jon Stafford

git statustells me that my branch and the one I started from on another repository have diverged:

git status告诉我我的分支和我从另一个存储库开始的分支已经不同:

# On branch master
# Your branch and 'origin/master' have diverged,
# and have 13 and 13 different commit(s) each, respectively.

but the commit history for each is identical. That is, git logshows the same commits, in the same order, with the same SHA-1 hashes. That's for the last 13 commits, and everything before that too.

但是每个的提交历史都是相同的。也就是说git log,以相同的顺序显示相同的提交,具有相同的 SHA-1 哈希值。这是最后 13 次提交,以及之前的所有提交。

What's going on?! Or have I misunderstood something fundamental - git's all new to me.

这是怎么回事?!或者我误解了一些基本的东西 - git对我来说是全新的。

It's quite a long story how I got into this mess - git-svn, cygwin, EGit, pull --rebase with spurious conflicts - but I'm wondering if it's possible this "divergence without any differences" is due to newlines? I've opened files in notepad, and read lots about svn/git/cygwin and CRLF but without any revelations.

我是如何陷入这种混乱的,这是一个很长的故事 - git-svn,cygwin,EGit,pull --rebase 与虚假冲突 - 但我想知道这种“没有任何差异的分歧”是否可能是由于换行造成的?我在记事本中打开了文件,并阅读了很多关于 svn/git/cygwin 和 CRLF 的内容,但没有任何启示。

EditOK. Most of the above isn't really the problem. Maybe I don't understand git logor something has got messed up somewhere...

编辑确定。以上大部分都不是问题。也许我不明白git log或某些地方搞砸了......

I have two repositories. If I go to rep_A and run git logI get the same result (notably same SHA-1) as if I go to rep_B and run git log.

我有两个存储库。如果我去 rep_A 并运行,git log我会得到相同的结果(特别是相同的 SHA-1),就像我去 rep_B 并运行git log.

At rep_A, if I run git log origin/masterI get the different commit history I expect. (Different SHA-1s, but same messages - how I created this mess is another story.)

在 rep_A,如果我运行,git log origin/master我会得到我期望的不同提交历史。(不同的 SHA-1,但相同的消息——我是如何制造这种混乱的则是另一回事。)

git remote -v showassures me that the origin is where I expect it to be.

git remote -v show向我保证起源是我期望的地方。

git log, on rep_B, isn't behaving how I expected. It's like it's giving me the commit history for rep_A. What have I missed?

git log,在 rep_B 上,行为不符合我的预期。这就像它给了我 rep_A 的提交历史。我错过了什么?

采纳答案by Michal ?iha?

It looks like you also forgot to update remote repositories. So do git remote updatein rep_A (it will probably warn it is not fast-forward update as you seem to do rebase on both ends) and then the histories should be identical.

看起来您还忘记更新远程存储库。所以git remote update在 rep_A 中做(它可能会警告它不是快进更新,因为你似乎在两端都做了rebase)然后历史应该是相同的。