Last active
July 6, 2021 10:38
-
-
Save thehig/ffdc48c4651c512ab9b8 to your computer and use it in GitHub Desktop.
git: gitconfig 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
[alias] | |
# Show last commits in nice format | |
last = log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=relative | |
# https://stackoverflow.com/questions/17195861/undo-git-update-index-assume-unchanged-file#17195901 | |
hide = update-index --assume-unchanged | |
unhide = update-index --no-assume-unchanged | |
# https://stackoverflow.com/questions/2363197/can-i-get-a-list-of-files-marked-assume-unchanged#37083903 | |
unhide-all = update-index --really-refresh | |
hidden = !git ls-files -v | grep \"^[a-z]\" | |
ignored = !git status -s --ignored | grep \"^!!\" | |
# https://github.com/mtyurt/dotfiles/blob/398f3d9f4e60b205f8649acc55f474debdbc1de7/bashrc#L29 | |
gdf = "!f(){ \ | |
echo 'Commits that exist in '$1' but not in '$2':';\ | |
git log --graph --pretty=format:'%Cred%h%Creset %s' --abbrev-commit $2..$1;\ | |
echo 'Commits that exist in '$2' but not in '$1':';\ | |
git log --graph --pretty=format:'%Cred%h%Creset %s' --abbrev-commit $1..$2;\ | |
};f" | |
# http://haacked.com/archive/2014/07/28/github-flow-aliases/ | |
co = checkout | |
# Edit the gitconfig in editor | |
ec = config --global -e | |
# Update working directory | |
up = !git pull --rebase --prune $@ && git submodule update --init --recursive | |
# Checkout new branch | |
cob = checkout -b | |
# Commit | |
cm = !git add -A && git commit -m | |
# Amend | |
amend = commit -a --amend | |
# Save/WIP | |
save = !git add -A && git commit -m 'SAVEPOINT' | |
wip = commit -am WIP | |
# Undo | |
undo = reset HEAD~1 --mixed | |
# Wipe (Reset, but with a commit thrown in) | |
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard | |
bclean = "!f() { git branch --merged ${1-master} | grep -v ${1-master}$ | xargs -r git branch -d; }; f" | |
bdone = "!f() { git checkout ${1-master} && git up && git bclean ${1-master}; }; f" | |
# Clean up local branches where remote is deleted | |
# https://www.erikschierboom.com/2020/02/17/cleaning-up-local-git-branches-deleted-on-a-remote/ | |
gone = ! "git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' | awk '$2 == \"[gone]\" {print $1}' | xargs -r git branch -D" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://haacked.com/archive/2014/07/28/github-flow-aliases/