Check Git Commit History
Want to check the git commit history? Simply execute the git log
command and it will bring the history of all the commits made on your current branch:
git log
Want more information? I got you.
How to check Git commit history
You can use the git log command in 3 ways to check the commit history:
git log
: it will show you the history of the current branch.git log <branch-name>
: it allows you to target a branch specifically and will show you the history of that specific branch.git log <file-path>
: it reveals the history of a specific file.
In simple terms using the git log command, you can specify various aspects of a git repository and get the desired results.
Show the commit history of the current branch
To show the history of the current branch, all you have to do is execute the git log
command without any additional flags:
git log
But for some users, the output may include the commit history of the other repositories as well (I'm coming to the reason in a minute):
In the above image, you can see that there's a commit of the MyRepo
branch even when I'm on the LHB
branch and the reason is simple.
While creating and switching to the new branch, you must have used the git checkout -b MyRepo
. The main culprit here is the -b
flag which carries the files of the previous branch resulting in a history containing information about the parent branch as well.
Show the commit history of a specific branch
To display the history of a specific branch, all you have to do is append the name of the branch to the git log
command as shown here:
git log <branch-name>
For example, if I want to see the history of the IF
branch, then I will be using the following command:
git log IF
Show the commit history of a file
If you want to target a file to check its commit history, then you can either append the file path or file name to the git log
command as shown:
git log <filename or path to file>
GitHub is real fun 😄
I personally think that GitHub is where the true version of controlling starts as you can share and contribute to the entire world.
And if you are a student and just getting started, then here's how to create a rockstar student GitHub profile:
Also, if you are using VSCode, here's how to connect to GitHub from the VSCode itself:
I hope you will find this guide helpful.