Delete all branches except master

git branch | grep -v "master" | xargs git branch -D

Checkout file from two commits ago

git checkout HEAD~1 -- filename

Resources