Skip to content

Instantly share code, notes, and snippets.

@shillcock
Created May 6, 2009 22:13
Show Gist options
  • Select an option

  • Save shillcock/107779 to your computer and use it in GitHub Desktop.

Select an option

Save shillcock/107779 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