This study will explain how to get the shortest possible output from the “git log” command containing the author’s name and date.
How to Get Shortest Output From ‘git log’ Containing Author and Date?
To get the shortest output from the git log command containing the author and date, check out the below-listed procedure:
- Redirect to the Git required repository.
- Execute the “git log –pretty=format:”%h %an %ad” –date=short <commit-range>”.
First, move to the Git root directory by running the “cd” command along with its path:
Execute the “git log“ command to get the author name and date:
Here:
- “–pretty” option is used to print the specified output data in a given format.
- “format:” allows you to specify desired information of the required commit.
- “%h” is used to get the short commit id.
- “%an” is used to print the author’s name.
- “%ad” provides the committing date by the author.
- “–date=short” option is used just to print the date instead of time in a readable format.
- “-5” is the particular range which means just printing the author name and date of the most recent 5 commits.
It can be observed that the below-provided output shows the SHA-hash of the last five commits, the author’s name, and the date in shortened:
That’s all! We have provided the easiest way of getting the shortest possible output from the “git log” command containing the author’s name and date.
Conclusion
To get the shortest possible output from the “git log” command containing the author and date, first, move to the Git required repository and execute the “git log –pretty=format:”%h %an %ad” –date=short <commit-range>”. This study demonstrated the method of getting the shortest possible output from the “git log” command containing the author’s name and date.