Add aliases by running each of the following commands once:
$ git config --global alias.rel "rev-parse --show-prefix"
$ git config --global alias.root "rev-parse --show-toplevel"
Example usage:
$ pwd
/Users/phrohdoh/src/dotnet-core-oauth2-server/cauth-mvc/Models/External/Slack
$ git root
/Users/phrohdoh/src/dotnet-core-oauth2-server/cauth-mvc
$ git rel
Models/External/Slack/
Bonus alias aliases
!
$ git config --global alias.aliases "! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /"
Run it to see something similar to the following:
$ git aliases
root = rev-parse --show-toplevel
rel = rev-parse --show-prefix
aliases = ! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /