This article looks at the best log aliases I use. Some I have found, some I have created and after reading you should be able to create your own easily.
Please feel free to submit your own in the comments below.
Add an alias
To add aliases, open your .gitconfig
file and you will see an alias section:
[alias] |
If you are on OSX, open a new command prompt and type:
open .gitconfig |
To use the alias, simply type:
git aliasname |
Log aliases
In no particular order:
1 - One liner with colors
Will log a list of commits, all on one line with customisable colours. Useful to know who has changed what on the repo recently.
l1 = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short |
2 - Graph one liner
Will log a list of commits with only the commit name and SHA. Useful to have a quick overview of the branches on the repo. I usually use the web UI for this, but this can be quicker if all you need is to refresh your memory.
l2 = log --graph --oneline --decorate --all |
Source (first comment)
3 - Search commit name history
Will search previous commits for a specific term. Useful if you want to find a specific comment based on the comment.
l3 = !git log --oneline | grep |
Use it like this
$ git log l3 JIRA # Will display all commits with 'JIRA' in the description |
4 - Details about the last commit
Will show all the differences introduced in the last commit.
l4 = log -p -1 |
5 - Get commits for n days before today
Another one by myself. It makes use of functions and displays the list of commits made before X days ago.
l5 = "!f() { \ |
Use it like this
$ git l5 15 # Get the commits made in the last 15 days |
Summary
I hope you found these useful, I will add more as I go.
Here is the list so far:
l1 = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short |
Thanks for reading !