This guide will provide the procedure of showing the commit history of Git one branch using the Git log command with range.
How to Show Commit History for One Branch Using Git Log With Range?
Suppose you want to show the two most recent commits log history. For this purpose, first, move to the Git directory. Then, display its content list. Open any file and update it. After that, utilize the “$ git log -2” command to show specific commits.
Let’s implement the above scenario through the provided steps!
Step 1: Launch Git Bash
Search and launch Git terminal with the help of the “Startup” menu:
Step 2: Navigate to Git Directory
Move to the “linux” Git directory using the “cd” command:
Step 3: Check Directory List
Next, execute the “ls” command to list the content of the current directory:
Step 4: Update File
Open the “file2.txt” file by utilizing the provided command:
As you can see, the “file1.txt” is opened in the Git default editor. Now, add some text, save it and exit the file:
Step 5: Commit Changes
Next, commit changes to the Git repository using the “git commit” command with the “-m” flag:
Step 6: Check Log History
Now, we will check the commit history of Git repository:
Here, “-2” indicates the range which means that we only want to display the history of the two most recent commits:
That’s it! We have offered the procedure of showing the commit history of Git one branch using the Git log command with range.
Conclusion
To show commit history for one branch using Git log with range, first, open up the Git terminal, and move to the Git directory. Then, list the whole content of the Git repository, open up any file and update it. Next, commit changes. Lastly, execute the “$ git log <range>” command with the range of commits for displaying their history. In this guide, we have demonstrated the method of showing the commit history of Git one branch using the Git log command with range.
from https://ift.tt/QGW5UzI
0 Comments