Visualising Branches And Their Commits | Git Show-branch

Commands discussed in this section:

  • git show-branch
  • gitg, gitk and qgit

Our Example Repository

Let’s start with the repository we created in the Creating And Playing With Branches section.

The master branch:

  • Commit C1: Created the file README with the contents: This is the README file.
  • Commit C2: Added one more line to the README file: One more line.
  • Commit C3: Created the file Makefile with the contents: #Beginnings of a Makefile

The test branch started with the master branch commit C2:

  • Commit T1 created the file Makefile with the contents: My system test

Visualize it

The below diagram shows the 2 branches and what occurred during each commit:

Depending on the platform where you’re running git, there are various GUIs that graphically show the branch history. Below is an example of the repository shown by running gitg –all (the –all flag is used to show all branches, instead of only the current branch):


In the top left area of the above image, below the word Subject, each circle represents a commit.

The most recent commit (“Added a Makefile“) on the master branch has been selected and highlighted. The actual changes to the repository for that commit are shown in the lower section of the window.

Is that nice, or what?

In addition to gitg, other git UIs that are common on Linux are gitk and qgit.

Both windows and MacOS versions of git also include a GUI, as mentioned in Where Do I Get Git?.

The git show-branch command can also be used: Decipher git show-branch to see branches and their commits

Next: Deciphering “git show-branch” to see branches and their commits
Previous: Creating And Playing With Branches


Switching Branches Without Committing
Temporarily Stashing Your Work

Recent Articles

What is the deal with the Git Index? What is the Git Index?

The git "index" is where you place files you want committed to the git repository. Learn more about the git index and git commit by selecting this link.

Visualising Branches And Their Commits | Git Show-branch

We explain and discuss the use of the git show-branch, gitg, gitk and qgit in this Tutorial. Complete with examples.

“Tracking Branches” And “Remote-Tracking Branches”

Both Tracking Branches and Remote Tracking Branches are created on the git client when a git clone command is used.

Temporarily Stashing Your Work

Git Stash is used when you want to record the current state of the working directory and index, without committing, to come back to complete later.

Shared Repositories Should Be Bare Repositories

Bare Repositories - When creating a central repository that will be shared by other users, the repositories should be created with the --bare option.

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox