How to show the commit history in a specific branch in Git

Arif Billah Babu

         

  git



Image not found!!


To show the commit history for a specific branch in Git, you can use the following command:

bash
git log <branch_name>

Replace <branch_name> with the name of the branch you're interested in.

For example, if you want to see the commit history for a branch named feature-branch, you would use:

bash
git log feature-branch

This command will display a chronological list of commits for the specified branch, showing details such as commit hash, author, date, and commit message.

You can also add additional options to the git log command to customize the output or view more details. For example:

  • To show a concise, one-line representation of each commit: git log --oneline <branch_name>
  • To include a graphical representation of the branch and commit history: git log --graph <branch_name>
  • To limit the number of commits displayed: git log -n <number_of_commits> <branch_name>

Feel free to explore the various options available with the git log command to tailor the output to your preferences.