Skip to content

Instantly share code, notes, and snippets.

@patricknelson
Created September 29, 2015 14:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patricknelson/56d0dd50622320e9f095 to your computer and use it in GitHub Desktop.
Save patricknelson/56d0dd50622320e9f095 to your computer and use it in GitHub Desktop.
When you're too stupid to realize you need to "git checkout [branch]" and not "cd" into it.
cd() {
if [ -d .git ] && [ ! -d $@ ]; then
git checkout "$@"
else
command cd "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment