Search code examples
gitgithubbranchupstream-branch

After git push -u origin exp:experimental is represented as master branch in the network graph


I'm just trying to understand if there's something strange in what I see on GitHub.

In my project there's the default master branch and a dev local branch with upstream counterpart named development. After some modification in the working directory I decided it would have been too difficult to proceed that way, so I decided to use git push -u origin exp:experimental to store the modification in a new branch (to be reused in a far future). What seems strange to me is that on the network graph on GitHub I see the line of this new branch painted black and on the same horizontal line of the master branch, as you can see in the following picture.

I fear this could be an alarm. Maybe what I obtained is not what I think I obtained. Maybe I misunderstanding some commands.

enter image description here


Solution

  • You're just misreading the graph, nothing to worry about.

    Despite its name, a graph (concept) isn't something that has a graphical representation. But we do like to render it in some way to help us understanding.
    Alas, there's un unlimited different ways to render the same graph (concept), which is often misleading for the user.

    With Git, a branch is just a label pointing to a commit (a blue or a black dot on your screenshot) and we usually consider that the branch contains all the commits from the first commit (the left of the graph image) until the branch label.

    With this explanation, you should be able to see that:

    1. The master branch is pointing at the 7th commit from the left and contains the 7 first commits.
    2. The development branch contains the same 7 commits, plus the 8 blue commits
    3. The experimental branch contains the 7 master commits, and 6 of the blue commits and then has a commit than only belongs to experimental yet.

    The fact that it is represented with the same color and vertical position than the master branch is just a choice of the renderer to re-use space and colors (and is probably what misled you).