Last active
October 30, 2024 17:26
-
-
Save NickPolyder/33a66cd3abb5d54c891c575678fba642 to your computer and use it in GitHub Desktop.
Git aliases for streamlined operations (insert on .gitconfig)
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] | |
s = status | |
co = checkout | |
cob = checkout -b | |
del = branch -D | |
br = branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate | |
save = !git add -A && git commit -m 'chore: savepoint' | |
undo = reset --soft HEAD~ | |
delete = push origin --delete | |
pull-updates = "!f() { (git stash && git checkout $1 && git pull --rebase && git checkout $2 && git rebase $1 && git stash pop) }; f" | |
push-updates = "!f() { (git stash && git checkout $2 && git pull --rebase && git checkout $1 && git rebase $2 && git checkout $2 && git merge --no-ff $1 && git push origin $2 && git checkout $1 && git rebase $2 && git stash pop) }; f" | |
sync-updates = "!f() { (git stash && git checkout $1 && git pull --rebase && git checkout $2 && git rebase $1 && git push origin --force-with-lease && git stash pop) }; f" | |
pull-create = "!f() { (git stash && git checkout $1 && git pull --rebase && git checkout -B $2 && git stash pop) }; f" | |
temp-ignore = update-index --assume-unchanged | |
temp-unignore = update-index --no-assume-unchanged | |
branch-rename = branch -m | |
change-branch = "!f() { (git stash && git checkout $1 && git stash pop) }; f" | |
check-local-stale-refs = "!f() { (git remote prune $1 --dry-run) }; f" | |
remove-local-stale-refs = "!f() { (git remote prune $1) }; f" | |
pu = "!f() { (git checkout $1 && git pull --rebase && git checkout $2 && git rebase $1) }; f" | |
open = !explorer$(git config remote.origin.url) | |
browse = !git open | |
stash-unstaged = "!f() { (git commit --message WIP && git add --all && git stash push -u -k && git reset --soft HEAD^ && git restore -S *) }; f" | |
stash-unstaged-m = "!f() { (git commit --message WIP && git add --all && git stash push -m \\$1\\ -u -k && git reset --soft HEAD^ && git restore -S *) }; f" | |
stash-all = "!f() { (git stash push -u -k ) }; f" | |
stash-all-m = "!f() { (git stash push -m \\$1\\ -u -k ) }; f" | |
squash-updates = "!f() { LASTMERGE=`git merge-base $1 $2`; git rebase -i --autosquash --autostash $LASTMERGE; }; f" | |
push-local = "!f() { (CURRENTBRANCH=`git branch --show-current`; git push --recurse-submodules=check origin refs/heads/$CURRENTBRANCH:refs/heads/$1; git refresh $1) }; f" | |
refresh = "!f() { CURRENTBRANCH=`git branch --show-current`; (git stash && git checkout $1 && git pull --rebase && git stash pop); git checkout $CURRENTBRANCH; }; f" | |
commits-since = "!f() { git log --graph --since=$1; }; f" | |
last-commits = "!f() { git log --graph $1; }; f" | |
head-hash = "!f() { git log -1 --pretty=%H $1; }; f" | |
head-summary = "!f() { git log -1 --summary $1; }; f" | |
c-history = !git log --max-count=10 --pretty='%Cred %H %Creset, Author: %an, %ar:%n%s%n' | |
track = "!f() { git branch --set-upstream-to $1; }; f" | |
untrack = branch --unset-upstream | |
whoami = status -b --porcelain | |
log-between = !sh -c 'git log $1..$2 --format=oneline "$@"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment