# Create and switch to the branch 'foo'
git checkout -b foo
# Check out a file from an earlier commit
git checkout c27cbab Gemfile
# The following command will create a local branch named foo, tracking the remote branch origin/foo. When you push your
# changes the remote branch will be updated.
git checkout --track origin/foo
# Get the foo.py file from origin develop into the current branch.
git checkout origin/develop foo.py
# Selectively checkout part of a file from a different branch
git checkout --patch branch_name -- file_name
# Create a local named `foo` based on `origin/bar`,
# but do not track `origin/bar`.
git checkout --no-track -b foo origin/bar
# Go back two versions
git checkout HEAD~2