Branch name in commits view


In the commits view panel of Source Tree, how can you view exactly on what branch it's a commit? I can see the different color lines from the left but it is not clear at all which is associated with that commit and what is the name of the branch associated with the line.

I really think something as enbling display of the branch name before the commit message would help.


Horatiu Graur

1 answer

1 accepted

0 votes
Accepted answer

In git, branches are never an attribute of a commit, they're simply pointers to a single commit which move as you commit to that branch, so the history is built by association via the parent links, and each commit has no branch information associated with it. This means moving branches around is very easy in Git, which is one of its strengths, although it can be confusing not to see an explicit branch in the commit metadata like you're used to in other systems. Technically the graph lines are just ancestry lines, not branch lines (although often the two are aligned).

In contrast, Mercurial does store branch information on every commit, so it's displayed in the commit details pane. This can be somewhat more intuitive than the Git way, but also not as flexible.

This means it's not doable?

I consider myself a beginner in Git so you are most likely right but what I don't get is the line colors from the left .. if they are associated with branches (as I imagine) I thought it should be possible .. but again maybe I misunderstood the lines role :)

If yes, let me know and I'll accept the answer.


No, it's not possible to label a commit with a branch, because every commit could be in the history of more than one branch in git.

The graph lines are associated with 'lines of development', which means each commit has one or more ancestors, the first one of which will normally considered the main ancestor and will have the same colour. In git, a branch is just a pointer to an end point, so you can follow a branch backwards from where it points to see its own history, and call the line which follows the first parent of each commit the 'branch line' if you want, but technically that's not what it is - the branch is just the end point, the rest is just a graph of ancestry for how you got there. Each commit itself is not assigned to a branch, it just happens to be in the parentage of where the branch points.

This is probably one of the trickiest things to grasp in git since it differs from almost every other VCS in not marking commits with a branch when the commit is made, but having branches as pointers (which can be changed of course!) instead.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

1,123 views 4 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you