# This is a handful of git commands I use on a daily basis, some of # which are pretty basic, some of which took a little research to # figure out how to do (so hopefully this is a time saver). It's # by no means an exhaustive list as git is really freaking robust. ######################## # logs ######################## # unmerged differences between dev and master (not including extra master commits) $ git log master...dev # unmerged differences between dev and master (including extra master commits) $ git log master..dev # nice visual changelog (thanks @jperras) # add this alias $ git config --global alias.lg "log --decorate --stat --graph --pretty=format:'%C(yellow)%h%Creset (%ar - %Cred%an%Creset), %s%n'" # then from now on $ git lg ######################## # working ######################## # amend last commit $ git commit --amend # stash changes for later (use -u to store files not in the index) $ git stash save "Working on this feature" # view a diff of that stash $ git show stash@{0} # store portions of a changed file in the index $ git add -p # remove portions of a changed file from the index $ git reset -p # after deleting or renaming a ton of files, remove them all from the index $ git rm `git ls-files -d` # view a diff of files in the index $ git diff --cached ######################## # branches ######################## # create and checkout a new branch $ git checkout -b newbranch # remove a branch (locally and remotely) $ git branch -d newbranch $ git push origin :newbranch