2

A few days ago I renamed a branch (following these steps) named emcee in my repo to emcee_old. Then, I created a new branch with the same name (emcee) but branching from a different point in my develop branch. Here's how Github shows this process:

enter image description here

The issue is that now if I check a file in the new emcee branch, it contains a commit that was made to that file in the old emcee. For example the .gitignore file in the new branch shows a commit that was made in 2017 in the old branch:

enter image description here

Even weirder is that if I access the history of that file (in the new branch) that commit is not there:

enter image description here

Why is going on here?

Gabriel
  • 40,504
  • 73
  • 230
  • 404
  • 2
    I've found GitHub's "network graph" to be error-filled and nearly useless, myself. – torek Mar 07 '18 at 19:55
  • So far I've had a good experience with Github's network graph and branch management. This issue threw me off completely. – Gabriel Mar 07 '18 at 19:57
  • 1
    Probably a matter of expectations, then. :-) I always have to clone the repository and examine the actual graph. The network graph appears to be intended for something to do with forks and other projects, and it may have some meaning there, but I have yet to decipher it. – torek Mar 07 '18 at 19:59
  • Also, I am by no means a `git` power-user like you (not even close), so our experiences with such a tool will clearly be different. For my level of `git` proficiency, the network graph is quite a useful feature. – Gabriel Mar 07 '18 at 20:03
  • 1
    @Gabriel I had the same issue documented here: https://github.com/isaacs/github/issues/955 – Gabriel Fair Mar 08 '18 at 03:03
  • 1
    @GabrielFair fortunately I didn't use GitHub's merge tool and did it all by hand. I have also contacted support, since my repo is public perhaps they can check what's going on and fix it. – Gabriel Mar 08 '18 at 03:06

1 Answers1

2

In short, Git does not carry commits between similarly-named branches.

So you created a branch, then renamed it and created a new one by the same name? I have done this in git v1.8.4.2 successfully, though without using Github.

I suspect an problem with Github's interface. You can test this by cutting it out of the loop and studying your repo's history locally, on the command line. Try running git log --graph --all command in a terminal window and study the output. This will display all of your branches, and their converging/diverging history. Also try git log --graph --all .gitignore to limit the history report to the file in question. I expect you will see a more predictable result, different from what Github displays.

This becomes more complex if there are other users of your repository. A collaborator could accidentally restore the old branch during a push. However your link indicates that you don't have to worry about this, as this is a solo effort.

Kevin Hencke
  • 168
  • 7
  • Thank you for the confirmation that this is some weird behaviour of Github and not just my imagination Kevin. – Gabriel Mar 07 '18 at 19:44
  • 1
    You're welcome. The 'git log' command has a lot of fancy options that make it a lot easier to visualize history. For example, [refer to this page.](https://coderwall.com/p/euwpig/a-better-git-log) – Kevin Hencke Mar 07 '18 at 22:49