Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Git Version Control Cookbook

You're reading from   Git Version Control Cookbook Leverage version control to transform your development workflow and boost productivity

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher
ISBN-13 9781789137545
Length 354 pages
Edition 2nd Edition
Tools
Arrow right icon
Authors (4):
Arrow left icon
Aske Olsson Aske Olsson
Author Profile Icon Aske Olsson
Aske Olsson
Emanuele Zattin(EUR) Emanuele Zattin(EUR)
Author Profile Icon Emanuele Zattin(EUR)
Emanuele Zattin(EUR)
Kenneth Geisshirt Kenneth Geisshirt
Author Profile Icon Kenneth Geisshirt
Kenneth Geisshirt
Rasmus Voss Rasmus Voss
Author Profile Icon Rasmus Voss
Rasmus Voss
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Navigating Git FREE CHAPTER 2. Configuration 3. Branching, Merging, and Options 4. Rebasing Regularly and Interactively, and Other Use Cases 5. Storing Additional Information in Your Repository 6. Extracting Data from the Repository 7. Enhancing Your Daily Work with Git Hooks, Aliases, and Scripts 8. Recovering from Mistakes 9. Repository Maintenance 10. Patching and Offline Sharing 11. Tips and Tricks 12. Git Providers, Integrations, and Clients 13. Other Books You May Enjoy

Viewing the history with gitk

We saw earlier how we can view the history (the DAG) and visualize it by using git log. However, as the history grows, the terminal representation of the history can be a bit cumbersome to navigate. Fortunately, there are a lot of graphical tools in Git, one of them being gitk, which works on multiple platforms (Linux, Mac, and Windows).

This recipe will show you how to get started with gitk.

Getting ready

Make sure you have gitk installed:

$ which gitk
/usr/local/bin/gitk

If nothing shows up, then gitk is not installed on your system, or at least is not available on your $PATH.

Change the directory to the Git-Version-Control-Cookbook-Second-Edition repository from the objects and DAG examples. Make sure the master branch is checked out and pointing to 13dcad:

$ git checkout master && git reset --hard 13dcad

How to do it...

In the repository, run gitk --all & to bring up the gitk interface. You can also specify the commit range or branches you want, just as you did with git log (or provide --all to see everything):

$ gitk --all &
Gitk shows the commit history of the repository:

How it works...

Gitk parses the information for every commit and the objects attached to it to provide an easy graphical information screen that shows a graph of the history, author, and timestamp for each commit. In the bottom half is the result of selecting a commit. The commit message and the patches for each file that has changed . Moreover, a list of files that have been changed is displayed to the right.

Though very lightweight and fast, gitk is a very powerful tool. There are many different context menus that appear after the user clicks on a commit, a branch, or a tag in the history view. You can create and delete branches, revert and cherry-pick commits, diff selected commits, and much more.

There's more...

From the interface, you can perform a find and search operation. Find looks through the history and Search looks through the information displayed in the lower half of gitk for the commit that is currently highlighted.

You have been reading a chapter from
Git Version Control Cookbook - Second Edition
Published in: Jul 2018
Publisher:
ISBN-13: 9781789137545
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime