One thing that always annoyed me is returning to top level directory in a git repo from somewhere deeper within.
It turns out that there’s a really simple solution – just make a bash alias
gitroot as follows.
alias gitroot='cd $(git rev-parse --show-toplevel)'
Put that line either in
~/.bashrc or if you use zsh in
~/.zshrc and you’re all set. Whenever inside a git repo and want to
cd to its root, typing
gitroot will take you to its root dir.