Skip to content

Instantly share code, notes, and snippets.

@jrk
Created May 11, 2009 20:02
Show Gist options
  • Select an option

  • Save jrk/110154 to your computer and use it in GitHub Desktop.

Select an option

Save jrk/110154 to your computer and use it in GitHub Desktop.
function gr {
## If the current working directory is inside of
## a git repository, this function will change
## it to the git root (ie, the directory that
## contains the .git/ directory), and then print
## the new directory.
git branch > /dev/null 2>&1 || return 1
cd "$(git rev-parse --show-cdup)".
pwd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment