Skip to content

Instantly share code, notes, and snippets.

@Balastrong
Last active May 7, 2024 12:08
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Balastrong/871b74afbe2f87515f424b4f19272f4b to your computer and use it in GitHub Desktop.
Save Balastrong/871b74afbe2f87515f424b4f19272f4b to your computer and use it in GitHub Desktop.
Some handy git aliases
# These aliases have been collected and shown in the making of this video, explaining how to set up and use git alises
# Source: https://youtu.be/Uk4GnYoQx_I
[alias]
# Shortcuts
ch = checkout
br = branch
st = status
br = branch
cm = commit -m
# Soft reset last commit
back = reset --soft HEAD~1
# Delete unstaged changes
hard = reset --hard
# info of last commit
last = log -1 HEAD
# More commands in one
aa = !git add -A && git status
cma = !git add -A && git commit -m
# Colored log
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
ls = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph
# Remove gone branches (no longer on remote)
gone = "!f() { git fetch --all --prune; git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D; }; f"
# Branches sorted by last modified
b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"
# List Aliases
al = "!git config -l | grep alias | cut -c 7-"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment