Skip to content

Instantly share code, notes, and snippets.

Created Aug 24, 2018
What would you like to do?
git aliases

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

$ git root

$ git rel

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/\ /\ =\ /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment