cd to git root
Ever been browsing around your git repo and wanted to quickly get back to your root? I use this function to teleport instantly:
function cd_git_root {
dir='.'
while [ ! -d "$dir/.git" ]; do
[ $(readlink -m $dir) = '/' ] && return
dir="../$dir"
done
cd $dir
}
Written by Fuad Saud
Related protips
2 Responses
Faster and easier is
cd $(git rev-parse --show-toplevel)
over 1 year ago
·
ahn, didn't know that one. thanks!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell script
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#