log

taiar

Git Snippets

Just some git snippets i’d like to remember.


Number of commits per author

$ git shortlog -s -n --all

Line changes per author

$ git log --author="author_name" --pretty=tformat: --numstat | gawk \
       '{ add += $1; subs += $2; loc += $1 - $2 } \
       END { printf "added lines: %s removed lines: %s total lines: %s\n", add, subs, loc }' -

Delete local branch

$ git branch -d branch_name

or

$ git branch -D branch_name

if it’s not fully merged and you want to delete anyway.


Delete all the merged branches (take care with master one)

$ git branch --merged | grep -v '^* ' | xargs git branch -d

Delete remote branch

$ git push origin --delete branch_name

Ignore modified files

$ git update-index --assume-unchanged file-name-here

Track the ignored files again

$ git update-index --no-assume-unchanged file-name-here

Git bissection

$ git bisect start
$ git bisect good 1234 (sha1 anywhere it works)
$ git bisect bad 5678 (sha1 anywhere it doesn't work)

then…

$ git bisect good

… if it works or …

$ git bisect bad

… if doesnt’t.

$ git bisect reset

… to restart.


Listing tags

$ git tag -l -n60

That’s it for now! :)