I haven’t been able to write many blog posts lately. I’ve been very busy and have lots to share, but for the time being I am going to release a series of cheat sheets I’ve been compiling for my own reference. Theses posts will continually be updated as I find more useful commands. I’ll kick the series off with Git; the best source control on the planet.
General
git show HEAD~5:file.txt
shows a file from 5 commits agogit diff HEAD^ — file.txt
difffile.txt
to the last commitgit diff master..remotes/origin/master
compares local master to remote origin mastergit diff --stat
summary of changes by file and line number changesgit rebase -i
interactively rebase your commits, for example to squash commits into one before pushinggit reset --hard HEAD
WARNING: reset your directory to the HEAD stategit init
initalize a repogit add --all
stage all changesgit commit -m "the first commit"
commit the changesgit checkout master -- file.html
checkout a file from another branchgit checkout HEAD -- file.html
checkout a file from HEADgit log -L 100,100:path/to/a/file.txt
history for a single line (e.g. line 100) in a file
Merge conflicts
git checkout --ours something.txt
git checkout --theirs something.txt