Book Image

Git for Programmers

By : Jesse Liberty
Book Image

Git for Programmers

By: Jesse Liberty

Overview of this book

Whether you’re looking for a book to deepen your understanding of Git or a refresher, this book is the ultimate guide to Git. Git for Programmers comprehensively equips you with actionable insights on advanced Git concepts in an engaging and straightforward way. As you progress through the chapters, you’ll gain expertise (and confidence) on Git with lots of practical use cases. After a quick refresher on git history and installation, you’ll dive straight into the creation and cloning of your repository. You’ll explore Git places, branching, and GUIs to get familiar with the fundamentals. Then you’ll learn how to handle merge conflicts, rebase, amend, interactive rebase, and use the log, as well as explore important Git commands for managing your repository. The troubleshooting part of this Git book will include detailed instructions on how to bisect, blame, and several other problem handling techniques that will complete your newly acquired Git arsenal. By the end of this book, you’ll be using Git with confidence. Saving, sharing, managing files as well as undoing mistakes and basically rewriting history will be a breeze.
Table of Contents (16 chapters)
11
Finding a Broken Commit: Bisect and Blame
13
Next Steps
14
Other Books You May Enjoy
15
Index

Metadata

Every commit, merge, and so on, is accompanied by metadata. You can get at a lot of the metadata by using the log, but sometimes you just want to extract a few pieces of important metadata. For that you can use the show command:

Figure 10.18: Using show to see metadata

In this example, we use show to find the name and email of the author, along with the ID and the metadata telling us where the tip of main is. Let's break it down:

  • git show—the show command.
  • -s—silent (or quiet), which suppresses the difference output (try the command without it to see).
  • HEAD tells show which commit you are interested in.
  • %an is the author's name.
  • %ae is the author's email address.

We put this code into a string and assign it to the format flag.

Let's look at the log and see what else we can do with showing metadata:

Figure 10.19: Looking at the log

Let's zero in on the metadata...