Last Updated: February 25, 2016
·
867
· alcedo

Git - Random stuff you can do with it

View number of commits per author:
git shortlog -s -n

Picture
(cant remember where i got this pic from)

Pretty git log:

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

Picture
Taken from: https://coderwall.com/p/euwpig

Search for commits that touches a particular line:

git log -S'todo'

Search for changes that is happening in a file:

git blame /pathto/file

Figure out which commit is causing problems on the site. Useful for rolling back commits:

  1. Find out last known good commit, eg: fd12345
  2. $ git bisect start
  3. $ git bisect bad 4 $ git bisect good fd12345 5 follow instructions on screen to mark commits as either good or bad. Git would in the end tell you which commit is bad.

Note: git is basically doing a binary search to figure out which commit is the bad commit

finish up by typing: $ git bisect reset

2 Responses
Add your response

This should be called, 'Random things you can do with Git', as none of it is essential. See http://rogerdudler.github.io/git-guide/ for git essentials....

over 1 year ago ·

agreed. i ended up not curating it properly as coderwall just keeps crashing on me =/

over 1 year ago ·