Terminology

git checkout — <filepath> Roll back changes to a modified file.

git checkout <branch>; git checkout <branch>~<n> <file> Revert a file <n> revisions.

git diff —name-only <commit>^..<commit> List the files modified in a particular commit.

git diff —name-only master List the files that are different between the current branch and the master branch.

git log -1 HEAD Show last commit on the current branch.

git log —name-only -1 <commit> List the files altered by the particular commit.

git log -p -1 <commit> Show the change made by a particular commit.

git log —pretty=oneline | grep <string> Find commit(s) with comments containing <string>.

git reset —hard HEAD~<n> Revert the previous <n> commits on the current branch.

git reset HEAD <file> Unstage a file to be committed.

git show <branch>:<filepath> Show a file as it exists in a particular branch.

git show <commit>:<filepath> Show the contents of a particular file as of a particular commit.

Facts, Thoughts and Opinions

git newbranch

Creates a branch, checks it out, and pushes it to the git server in one command.

!f(){ git branch $1 && git checkout $1 && git push -u origin $1; };f

parse_git_dirty

Returns the name of the current git branch.

function parse_git_branch () {
       git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}