Last active
November 8, 2024 13:58
-
-
Save Korko/9188588 to your computer and use it in GitHub Desktop.
Some functions to help use of git with CR and stuff by Gerrit
This file contains hidden or 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
# Git configs | |
git config --global color.branch auto | |
git config --global color.diff auto | |
git config --global color.interactive auto | |
git config --global color.status auto | |
git config --global color.ui auto | |
# Git basic aliases | |
git config --global alias.r reset | |
git config --global alias.co checkout | |
git config --global alias.ci commit | |
git config --global alias.cp cherry-pick | |
git config --global alias.br branch | |
git config --global alias.st 'status -sb' | |
git config --global alias.up 'pull --rebase --autostash' | |
git config --global alias.lg 'log --graph --decorate --oneline --abbrev-commit --stat' | |
# Git tool aliases | |
git config --global alias.bn '!(git rev-parse --abbrev-ref --symbolic-full-name @{u})' | |
git config --global alias.bnl '!(git bn | sed "s/gerrit\///")' | |
git config --global alias.topic '!(git rev-parse --abbrev-ref HEAD)' | |
# Git usefull aliases | |
git config --global alias.rco '!f() { git reset $1 && git checkout $1; }; f' | |
git config --global alias.draft '!(git up && git push gerrit HEAD:refs/drafts/$(git bnl))' | |
git config --global alias.publish '!f() { git up && if ! [ -z "$1" ]; then git push gerrit HEAD:refs/publish/$(git bnl)/$1; else git push gerrit HEAD:refs/publish/$(git bnl); fi }; f' | |
git config --global alias.tmp '!f() { bn=${1:-`git bn`} && git stash save -u -k && git co -b temp/$(echo $bn | sed "s/gerrit\///" | sed "s/tags\///")-$$ $bn && git stash pop -q; }; f' | |
git config --global alias.back '!(git stash -u && bn=$(git topic) && git co master && git stash pop -q ; git br -D $bn)' | |
# stash / checkout new branch with temp name / commit / publish / checkout master / remove temp branch | |
git config --global alias.mantis '!f() { git tmp && if [ $# -ge 2 ]; then git ci -m "[CR] Mantis #$1 - ${@:2}"; else git ci -em "[CR] Mantis #$1 - "; fi && git publish mantis_$1 && git back; }; f' | |
git config --global alias.dev '!f() { git tmp && if [ $# -ge 2 ]; then git ci -m "[CR] $1 - ${@:2}"; else git ci -em "[CR] $1 - "; fi && git publish $1 && git back; }; f' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment