Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Branch name in commits view

Horatiu Graur October 1, 2012

Hi,

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.

Thanks!

Horatiu Graur

1 answer

1 accepted

0 votes
Answer accepted
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 1, 2012

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.

Horatiu Graur October 1, 2012

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.

Thanks!

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 2, 2012

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
TAGS
AUG Leaders

Atlassian Community Events