Does a branch identify a commit, or does a commit identify a branch?

A disparity between conceptual Git branching diagrams and actual Git branching diagrams

Here is a relatively famous picture illustrating some branches in a git repository:

In this diagram, each vertical line is supposed to be a branch. Each commit in the diagram sits on one of those vertical lines. Look at any other diagram that someone has made to illustrate how branching works in Git, and you’ll find the same thing. The idea is that every commit belongs to a particular branch. This is how we think and talk about branches in Git.

But it is a lie, isn’t it? Because in the Git data model, a branch is just a pointer to a commit. The model is not that every commit has a property that identifies a branch; it’s that every branch has a property that identifies a commit.

One way to see the incorrectness of the ‘intuitive’ model is to observe that you can have two branches pointing to the same commit. How would we draw this in the above diagram?

Another way is to observe that the initial commit in the repository must be on all branches; not just on the master branch.

Can we recover the intuitive diagram from the Git data model? I can think of three sources to do so:

  • Git commit parents are an ordered list?
  • Git merges say what branch they merged from, if they merged a branch.
  • Git reflog gives us the local history of a branch pointer.




Developer of TigYog — (I don’t blog here any more; see

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
James Fisher

James Fisher

Developer of TigYog — (I don’t blog here any more; see

More from Medium

Where can I promote my music video?

Your Accounts are Down! Now What?!

CS371p Spring 2022: Lance Nguyen: Final Entry

Warsaw, Poland News Conference — May 17, 2022 — American proposes Nobel Peace Prize for Poland