Skip to content

Instantly share code, notes, and snippets.

@nicolas-oliveira
Created September 19, 2024 22:46
Show Gist options
  • Save nicolas-oliveira/428e73f696678fa2a3b2c19b3ab48403 to your computer and use it in GitHub Desktop.
Save nicolas-oliveira/428e73f696678fa2a3b2c19b3ab48403 to your computer and use it in GitHub Desktop.
Aliases in git

Aliases for git


git delete-local
git aliases
git url

Better log

usage:

git lg

config:

git config alias.lg "log --color --graph --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --branches"

undo

usage:

git undo

config:

git config alias.undo "git reset HEAD~"

List aliases

usage:

git aliases

config:

git config --global alias.aliases "!git config --get-regexp ^alias | awk 'BEGIN { print \"\033[1;34mAlias\033[0m\t\t\t\033[1;32mCommand\033[0m\"; print \"------\t\t\t-------\" } \$1 != \"alias.aliases\" { alias_color = \"\033[1;36m\"; command_color = \"\033[1;33m\"; reset_color = \"\033[0m\"; alias_length = 20; alias_name = substr(\$1, 7); printf \"%s%-\" alias_length \"s%s\t%s%s%s\n\", alias_color, alias_name, reset_color, command_color, substr(\$0, index(\$0, \$2)), reset_color }'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment