Git Better

January 28, 2016

In this video, Steve Smith manages to explain what some of the Git operations actually do. It is very visual and the best explanation of Git that I have ever seen. Also, at the end (starting from 39:25) he gives a compelling argument to why you should work with pull requests if you are using Github. Just watch it!


$ git init
$ git status
$ git add file1 file2
$ git commit -m "Added files"


  • Soft: move HEAD

  • Mixed: move HEAD and update the index

  • Hard: move HEAD, reset index and working directory

$ git reset --soft HEAD~1
$ git reset HEAD~1
$ git reset --hard HEAD~1


$ git stash -u
$ git stash save -u 'Description' 
$ git stash list
$ git stash show
$ git stash show stash@{0}
$ git stash pop
$ git stash apply
$ git stash branch new-branch-name stash@{0}


$ git log
$ git reflog
$ git reset --hard d59baaf
$ git checkout -b new-branch-name d59baaf
$ git reflog show feature-branch
$ git reflog show master@{1.week.ago}

Interactive rebase

$ git rebase -i HEAD~8


$ git blame lib/index.js
$ git show a8fd0459


# Soft reset: git undo
$ git config --global alias.undo 'reset --soft HEAD~1'

# Mixed reset: git unstage
$ git config --global alias.unstage 'reset HEAD --'