Skip to content

Instantly share code, notes, and snippets.

@samuelsmal
Created November 6, 2014 01:22
Show Gist options
  • Save samuelsmal/a5a45f8e8f9d06fd2e10 to your computer and use it in GitHub Desktop.
Save samuelsmal/a5a45f8e8f9d06fd2e10 to your computer and use it in GitHub Desktop.
List of helpful command line commands

This answer builds upon the answer by johnny. I got it from stackoverflow user A-B-B.

It applies if you're not using git-alias from git-extras.

On Linux, run once:

git config --global alias.alias "! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /"

This will create a permanent git alias named alias which gets stored in your ~/.gitconfig file. Using it will list all of your git aliases, in nearly the same format as they are in the ~/.gitconfig file. To use it, type:

$ git alias
lba = log --graph --decorate --name-status --all
alias = ! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /

The following optional considerations apply:

  • To prevent the alias alias from getting listed as above, append | grep -v ^'alias ' just before the closing double-quote. I don't recommend this for Linux users so that they don't forget that the the command alias is but an alias and is not a feature of git.

  • To sort the listed aliases, append | sort just before the closing double-quote. Alternatively, you can keep the aliases in ~/.gitconfig sorted.

  • To add the alias as a system-wide alias, replace --global (for current user) with --system (for all users).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment