> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Check Git Commit History
- URL: https://linuxhandbook.com/git-commit-history/
- Published: 2024-09-08T10:50:44.000Z
- Updated: 2024-09-08T10:50:44.000Z
- Description: Learn to quickly check the commit history in git.
- Author: Sagar Sharma
- Tags: Using Git, #docs-col

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
```

![list git commit history](https://linuxhandbook.com/content/images/2024/02/list-git-commit-history-1.png)

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 
```

![Show the commit history of the current branch](https://linuxhandbook.com/content/images/2024/02/Show-the-commit-history-of-the-current-branch.png)

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):

![Diffrent branches are shown while using git log command](https://linuxhandbook.com/content/images/2024/02/Diffrent-branches-are-shown-while-using-git-log-command-1.png)

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 specific branch in git](https://linuxhandbook.com/content/images/2024/02/Show-the-commit-history-of-a-specific-branch-in-git.png)

### 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>
```

![Check the commit history of a file](https://linuxhandbook.com/content/images/2024/02/Check-the-commit-history-of-a-file.png)

## GitHub is real fun 😄

I personally think that [GitHub](https://github.com/?ref=linuxhandbook.com) 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](https://linuxhandbook.com/github-profile-tips/):

[7 Tips to Make a Rockstar Student Developer GitHub ProfileTime to enhance the look and feel of your boring default GitHub profile with these tips and suggestions.![](https://linuxhandbook.com/content/images/size/w256h256/2021/08/Linux-Handbook-New-Logo.png)Linux HandbookPrakhar Tiwari![](https://linuxhandbook.com/content/images/2024/01/best-practices-for-rockstar-student-developer-profile.png)](https://linuxhandbook.com/github-profile-tips/)

Also, if you are using VSCode, here's [how to connect to GitHub from the VSCode itself](https://itsfoss.com/vs-code-github/?ref=linuxhandbook.com):

[How to Connect GitHub to VS Code \[Step by Step\]Take your coding experience to the next level of ease by integrating GitHub into VS Code.![](https://itsfoss.com/content/images/size/w256h256/2022/12/android-chrome-192x192.png)It's FOSSAbhishek Prakash![](https://itsfoss.com/content/images/2023/04/integrate-github-with-vscode.png)](https://itsfoss.com/vs-code-github/?ref=linuxhandbook.com)

I hope you will find this guide helpful.