Last active
November 9, 2024 14:10
-
-
Save Balastrong/871b74afbe2f87515f424b4f19272f4b to your computer and use it in GitHub Desktop.
Some handy git aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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