Mastering Git
If you have been working with Git, you might be familiar with git log
command. Beyond its basic usage (i.e. plain git log
), the advanced use of this command can be quite powerful, making navigation of repository’s history seamless and informative. In this post, we will learn a few useful ways to use git log
to bring your Git knowledge to the next level.
This post assumes that the reader, you, are familiar with the basic usage of Git. If you need a refresher on Git basics, you may want to check out this article first. To make most of this post, I encourage you to practice using the commands as you read through the article. We learn faster when we are actively practicing new knowledge than passively reading through it.
We will use one of my favourite GitHub repository: ABSphreak/readme-jokes: 😄 Jokes for your GitHub READMEs to demonstrate the use of commands. This awesome lightweight repository allowed me to include random programming jokes in my GitHub profile. Let’s start by cloning the repo locally, go inside the repository and run simple git log
to refresh how the command outputs look like:
git clone https://github.com/ABSphreak/readme-jokes
cd readme-jokes
git log
The output quickly fills up our window and is bit wordy. Some details such as email address in the output may not be particularly useful most of the time. Let’s learn how to get more succinct log.
If you simply want to check previous commit messages without extra details, we can add --oneline
option to get more concise output:
git log --oneline