- sorting
- filtering
- output formatting
How to get the git log in a "Sorting order"?
Using the --pretty value with Oneline to going to give you the log output in simplify format.
git log --pretty=onelineThe output combination of COMMIT_ID COMMIT_MESSAGE | Branch level changes
How to do Filtering while getting the git-log output?
- author - User name of the commit made by
- date ranges - We have date options with --before and --after where date can be given in "YYYY-MM-DD" format
- regular-expressions - Linux grep like option --grep that takes any text patter to filter
- path - file or directory path can be used to narrow down your log filtering
Find the commit history of a user
git log --author="AUTHOR NAME"
For example: Find all code changes done by user "Rajasekhar"
Find History in range of dates
git log --before="date1" --after="date2"
For example: Find all commits between 19th Feb to 26th Feb 2021
Commit History with a regular expression
Git commit history can be extracted with the regular expression that matches to the word or pattern that matches the existing commit messages.git log --grep="PATTERN"For example, find all the 'commit's having an "adding" pattern.
Commit history of a given path
We can use the current work-tree contained in any one of the folders as the path to check the history of that particular directory.git log -- [PATH]
git log -- . # current folder git log -- WebLogic/samples # specific directory history git log -- README.md # specific file history
what is happening in this directory? |
Commit History of a file |
What happened since the date?
git log --since="YEAR-MM-DD"
Since date onwards commit changes |
In most of the real scenarios we need to know the files which are changed recently. This git-log command with the oneline option and abbreviated commit id helps us to have a simple view
git log --pretty=oneline --abbrev-commit
You can use this for more combinations as per your project requirements To get all oneliner logs with short commit id and filtered with specific author changes:
git log --pretty=oneline --abbrev-commit --author "Bhavani"To get all oneline logs with short commit id for all changes made for "WebLogic" pattern matched in the commit messages.
git log --pretty=oneline --abbrev-commit --grep "WebLogic"