When I’m writing examples, it is often nice to have very short commit hashes. The --abbrev=3
argument, passed after the --oneline
flag, allows me to reduce the number of characters in the commit to 3
.
git log --oneline --abbrev=3
Output
6f5d (HEAD -> main) Add d.txt
e45b Merge branch 'feat/c'
330c Add c.txt
c145 Add b.txt
f6c7 Add a.txt
8044 Initial commit
Typically, I also want to use the --graph
flag.
git log --oneline --graph --abbrev=3
Output
* 6f5d (HEAD -> main) Add d.txt
* e45b Merge branch 'feat/c'
|\
| * 330c Add c.txt
|/
* c145 Add b.txt
* f6c7 Add a.txt
* 8044 Initial commit
Leave a Reply