How to easily get back to the root of a Git repo
Have you ever been in a directory within a Git repository and you needed to get back to the top level?
To find the path, run git rev-parse --show-toplevel.
For example, when I'm within the repository for this website:
Code/oliverdavies.uk/app/config > git rev-parse --show-toplevel
/home/opdavies/Code/oliverdavies.uk
I have this set as a Git alias called root:
$ git help root
'root' is aliased to 'rev-parse --show-toplevel'
Now, anywhere within a repository, I can run cd $(git root) and easily get back to the top level.