Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Branches have apparently diverged, but commit history is identical

Tags:

git

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

# 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 log shows 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.

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

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.

Edit OK. Most of the above isn't really the problem. Maybe I don't understand git log or something has got messed up somewhere...

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

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

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

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?

like image 714
Jon Stafford Avatar asked Feb 19 '10 18:02

Jon Stafford


People also ask

What does diverged mean in git?

A branch in git is a series of interrelated commits. If two branches follow a non-linear path then they diverge each other.

What does git branch command do?

The git branch command lets you create, list, rename, and delete branches. It doesn't let you switch between branches or put a forked history back together again. For this reason, git branch is tightly integrated with the git checkout and git merge commands.


1 Answers

It looks like you also forgot to update remote repositories. So do git remote update in 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.

like image 63
Michal Čihař Avatar answered Oct 13 '22 13:10

Michal Čihař