How to read the Graph in SourceTree, part 2

I found this other question here that seeks general understanding of the SourceTree history graph. There was a start of an answer, but I want to take it further. I'd love to get pointers to documentation or other helpful information. However, I will ask a few specific questions about this particular case.

sourcetree.png

For the given Git repository, I have 8 branches local and I have highlighted an additional branch that is only remote.

  1. How can I tell which vertical track goes with which branch?
  2. The diagonal lines I understand as indicators of merging and branching. Some of these have one colored circle end point anchored on one of the tracks, but none have two. How do I tell which branch they came from or are going to. 
  3. Many of the lines push right past the rightmost track. Does that indicate they are anchored to a branch not shown?
  4. How can I control which branches are shown?
  5. With the branch highlighted, I get the blue bar across the graph/description windows. That doesn't indicate a merge or branch - so what is happening there?

Of course, any pointers to further documentation would be greatly appreciated. 

 

2 answers

1 accepted

3 votes
Accepted answer
  1. You can't. Despite the visual image brought to mind by the word "branch", in Git, a branch refers to one commit. Each commit can have one or two parents. The graph is just a visual representation of that chain of relationships. If you want to find what branch(es) are descendants of a line, you can only scroll up until you find commits on the line that have connected branches.
  2. The diagonal lines should always go "to" a commit. To find where they come from, follow them to the opposing vertical line, then follow that line down to the first commit on that line. The only know way to know what branch(es) were involved at the time of the merge is if the committer listed them in the commit comment.
  3. No, it means the display area for the graph isn't wide enough. You can click and drag between the column headers to resize it.
  4. You can control which branches are shown at the top, but options are limited. You can show just the current branch, or all branches. You can also choose whether the graph should include remote branches or not (origin/...).
  5. It indicates a commit that is on a line that is outside the visible part of the graph. As mentioned in (3), resize the graph to find the dot representing that commit. EVERY row in that list represents a commit, and will have a corresponding dot on the graph.

 

@Seth, it appears that you and I were writing the same answer at the same time!

Yeah, good to have both though as confirmation/clarification.

Agreed, @Seth. As my brother is fond of saying, "GMTA!" (Great minds think alike!) LOL

First of all, may I suggest you get a good book or online training course on Git and study up? Getting these concepts straightened out will serve you well if you are going to be using Git.

The commit, not the branch is the fundamental unit of work in Git. Everything depends on the commit. A branch is nothing more than a pointer to a specific commit. This is true even for master and HEAD. I think you might be confusing these two concepts which leads to your questions.

  1. You can't because the vertical tracks do not necessarily go with a specific branch. These tracks follow the lineage – parent to child – from one commit to the next. This lineage is fundamental to Git's operation. 
  2. These lines show lineage, .e.g., commit 22e4035 is parent to commit 2394ed5. The branch, is only a pointer to the commit that is the current "top-of-the-world" for the branch. Remember this: a branch can be deleted, a commit cannot. 
  3. The lines that run to the right are showing lineage to a commit that exists, but that is not visible. Go to the Graph column header and stretch the column to the right. They'll appear.
  4. Use the button above the Graph column header. It defaults to "All Branches". You can change it to "Current Branch". There are no other options currently.
  5. That blue bar isn't highlighting the branch. It is highlighting a commit. You see a branch name here, because that branch current points to that commit. A commit means that something that was changed was committed to the repository. That could be a merge or a branch or just checking in some files that were edited.

Hope that helps.

YW, @Kevin Buchs.

Commits that do not have any connection to any branch or tag label will not show up in the Sourcetree ui or git log, so deleting a branch can make 9,000 commits just disappear.

If you had recently checked out the branch before you deleted then a reference to it will be shown in the git reflog command list and you can then create a new branch or tag from the commit hash shown there. 

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...

846 views 3 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