Refs
HEAD^       # 1 commit before head
HEAD^^      # 2 commits before head
HEAD~5      # 5 commits before head
Branches
  git checkout -b $branchname
  git push origin $branchname --set-upstream
  git fetch origin
  git checkout --track origin/$branchname
  git remote prune origin
  git branch -a --merged
  git push origin :$branchname
  
  git checkout -
Collaboration
  git pull --rebase upstream master
  
  git rebase -i $commit_ref
Submodules
# Import .gitmodules
  git submodule init
# Clone missing submodules, and checkout commits
  git submodule update 
# Update remote URLs in .gitmodules
# (Use when you changed remotes in submodules)
  git submodule sync
Diff
Diff with stats
git diff 
app/a.txt    | 2 +-
app/b.txt    | 8 ++
2 files changed, 10 insertions(+), 84 deletions(-)
Just filenames
git diff --summary
Log options
  e11e9f9 Commit message here
  shows "(origin/master)"
  shows graph lines
  "2 hours ago"
Misc
Cherry pick
git rebase 76acada^
Misc
  git show-ref HEAD -s
  git log -1 f5a960b5
  cd "$(git rev-parse --show-top-level)"
Short log
 $ git shortlog
 $ git shortlog HEAD~20..    # last 20 commits
 James Dean (1):
     Commit here
     Commit there
 Frank Sinatra (5):
     Another commit
     This other commit
Bisect
git bisect start HEAD HEAD~6
git bisect run npm test
git checkout refs/bisect/bad   # this is where it screwed up
git bisect reset
Manual bisection
git bisect start
git bisect good   
git checkout HEAD~8
npm test          
git bisect bad    
git bisect reset  
Searching
git log --grep="fixes things"  
git log -S"window.alert"       
git log -G"foo.*"              
GPG Signing
git config set user.signingkey <GPG KEY ID>       # Sets GPG key to use for signing
git commit -m "Implement feature Y" 
git config set commit.gpgsign true                # Sign commits by default
git commit -m "Implement feature Y"