See which Git command you use the most
Paste this into your terminal:
history|grep git| awk '{CMD[$3]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
Increase -n to see more commands.
Example output (my own):
1 385 8.68095% log
2 318 7.17024% co
3 309 6.96731% commit
4 307 6.92221% show
5 254 5.72717% push
6 231 5.20857% add
7 151 3.40474% branch
8 140 3.15671% tag
9 113 2.54791% reset
10 112 2.52537% clone
Source/adapted from http://superuser.com/a/250230/94027
Written by Thomas Ferris Nicolaisen
Related protips
11 Responses
1 51 22.973% svn
2 51 22.973% checkout
3 38 17.1171% branch
4 19 8.55856% log
5 13 5.85586% rebase
6 10 4.5045% status
7 8 3.6036% cherry-pick
8 6 2.7027% commit
9 4 1.8018% reset
10 3 1.35135% merge
Can you tell I'm still using git-svn ? :)
1 294 19.8649% st
2 143 9.66216% add
3 114 7.7027% commit
4 84 5.67568% log
5 78 5.27027% push
6 77 5.2027% pull
7 55 3.71622% co
8 54 3.64865% stash
9 42 2.83784%
10 34 2.2973% config
1 1033 23.6927% checkout
2 939 21.5367% commit
3 418 9.58716% status
4 250 5.73394% reset
5 238 5.45872% push
6 222 5.09174% add
7 194 4.44954% branch
8 187 4.28899% merge
9 171 3.92202% log
10 90 2.06422% diff
Modified for zsh:
grep git ~/.histfile | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
And my results: (co is checkout, ls is status)
1 135 32.2196% commit
2 36 8.59189% add
3 21 5.01193% co
4 19 4.53461% push
5 18 4.29594% rm
6 18 4.29594% clone
7 11 2.6253% ls
8 10 2.38663% rebase
9 7 1.67064% reset
10 7 1.67064% pull
Not bad ...
1 34 17.6166% push
2 33 17.0984% add
3 30 15.544% status
4 30 15.544% commit
5 16 8.29016% pull
6 11 5.69948% clone
7 6 3.10881% remote
8 4 2.07254% init
9 2 1.03627% git-server
10 2 1.03627% reset
"ci" is an alias of commit, "co" an alias of checkout...
1 527 23.9328% ci
2 217 9.85468% add
3 168 7.62943% co
4 100 4.54133% commit
5 91 4.13261% diff
6 90 4.08719% clone
7 73 3.31517% push
8 67 3.04269% reset
9 62 2.81562% log
10 57 2.58856% stash
@passcod there's no need to do cat ~/.histfile | grep git
, it's much better to do grep git ~/.histfile
.
I've adapted to read my ~/.bash_history instead, though it's pretty much the same script:
grep ^git ~/.bash_history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
My results are:
1 18 15.2542% co
2 15 12.7119% st
3 14 11.8644% ci
4 12 10.1695% push
5 9 7.62712% s
6 7 5.9322% di
7 7 5.9322% add
8 5 4.23729% rebase
9 5 4.23729% l
10 5 4.23729% fetch
-
co
: checkout -
st
: status -
ci
: commit -
s
: status -sb -
di
: diff -
l
: git --no-pager log -1 --name-status
I mostly checkout via a shell alias 'gco', and check status with a 'gst' alias, but other than that I grep a -lot-.
1 183 18.6735% grep
2 58 5.91837% commit
3 47 4.79592% clone
4 39 3.97959% checkout
5 34 3.46939% add
6 31 3.16327% branch
7 30 3.06122% show
8 29 2.95918% rm
9 29 2.95918% diff
10 27 2.7551% log
@passcod @inkel: in zsh, it's better to use
history 1 . | .......
or ${HISTFILE} instead of ~/.histfile
My most used git commands
1 51 13.8965% log 2 50 13.624% co 3 22 5.99455% diff 4 22 5.99455% commit 5 18 4.90463% reset 6 17 4.63215% stash 7 17 4.63215% clone 8 17 4.63215% add 9 15 4.08719% merge 10 14 3.81471% cot
It seems zshell has a tendency to re-use elements of the history file, so commands like git status
that are used identically many times leads to a single entry in the history file, and therefore the statistics get all wrong.