How to use Git Client to Trace Commit History

Image for post
Image for post

Git is good to keep track of your code changes, especially if you do commit every time you proceed each step when you do Test-Driven Development (TDD). Moreover, you can share to others on how did you do TDD step-by-step with explanation in the commit message.

Before starting with Git, get yourself familiar with it first from this blog: Learn Git within 7 Minutes and Play Around with It. Or you can follow steps below on how you can use Git client to track code changes.

I. Git Client in Eclipse

1. Open Git perspective in Eclipse by go to menu Windows Perspective Open PerspectiveOther…

Image for post
Image for post

2. Select Git and click OK

Image for post
Image for post

3. On the left pane, you can click to Clone a Git repository or Add an existing local Git repository. In this case, I will clone a Git repository from GitHub.

Image for post
Image for post

Or you can click the icon on the top-right corner.

Image for post
Image for post

4. Get the Git repository URL. In this case, I copied URL from GitHub.

Image for post
Image for post

5. Paste the URL in the URI field and it automatically populates other fields. You may change the URL protocol from to if you encouter the error “cannot open git-upload-pack”.

Image for post
Image for post

6. Select branch to clone. In this case, there’s only one master branch to clone. Click Next.

Image for post
Image for post

7. Select directory you want to keep this Git repository on your local machine. Click Finish.

Image for post
Image for post

8. Wait until the operation is completed.

Image for post
Image for post

9. Now, you can see your Git repository in the left pane.

Image for post
Image for post

10. Right click on the repository and select Show InHistory

Image for post
Image for post

11. You will see the Git commit history appear on the right pane. The history is listed in anti-chronological order.

You can click one of them to see what files had been changed in that commit. You can double click the file to see the change.

Image for post
Image for post

12. You can see the file content at selected commit from the above view.

Image for post
Image for post

II. Git GUI

If you install Git client from https://git-scm.com/downloads then you can follow theses steps:

  1. Run Git GUI and select either Clone Existing Repository or Open Existing Reposiory. In this case, I will open existing local repository.
Image for post
Image for post

2. Select directory of your local Git repository and click Open

Image for post
Image for post

3. Go to menu Repository Visualize master’s History

Image for post
Image for post

4. A new window will popup with all commit history which you can choose and the change detail will be shown below.

I found this is more user-friendly to explore than it is in Eclipse. However, I cannot find an easy way to view the file at specific commit without checkout or revert. Please let me know if you know how.

Image for post
Image for post

III. GitHub Desktop

If you are using GitHub Desktop (downloadable from https://desktop.github.com/) then you can follow these steps:

1. Open GitGub Desktop and Click + on the top-left and choose either Add or Clone tab. In this case I choose Add to add existing local Git repository. Select your local Git directory and click Add repository.

Image for post
Image for post

2. On the right panel, select History tab. It will list all commit history in anti-chronological order with changes of the commit showing on the right pane.

However, same as Git GUI, I cannot find a way to display the file content at specific commit without checkout or revert. Please let me know if you do know.

Image for post
Image for post

IV. Summary

  • If you want to just explore and trace changes in each commit, Git GUI or GitHub Desktop are more user-friendly.
  • If you want to see the full file content at specific commit then Eclipse may be a better choice. (Until I can find way to do the same in Git GUI or GitHub Desktop 😊)

Related Blog

Originally published at pacroy.blogspot.com on January 29, 2017.

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