Skip to content

Instantly share code, notes, and snippets.

@zenzora
Created January 24, 2017 19:26
Show Gist options
  • Save zenzora/2644bb4577ed133d748a186c5f971171 to your computer and use it in GitHub Desktop.
Save zenzora/2644bb4577ed133d748a186c5f971171 to your computer and use it in GitHub Desktop.
Step back to the root of a git repo
##Added the following to my .bashrc, thought I'd share
function groot() {
if [ -d '.git' ]
then
echo "I AM GROOT"
fi
startDir=${PWD}
while [ ! -d '.git' ]
do
if [ ${PWD} == '/' ]
then
echo 'No gitroot found'
cd $startDir
return;
fi
cd ..
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment