Skip to content

Instantly share code, notes, and snippets.

@LazyRen
Last active Jul 22, 2021
Embed
What would you like to do?
git-related alias.
# copy current file to $ZSH_CUSTOM
alias ga="git add"
alias gaa="git add --all"
alias gb="git branch"
alias gba="git branch -a"
alias gc="git commit"
alias gca="git commit --amend"
alias gcm="git commit -m"
alias gco="git checkout"
alias gd="git diff"
alias glog="git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"
alias gm="git merge"
alias gp="git push"
alias gpl="git pull"
alias gs="git status"
# Gerrit
gpg() {
if [ -z "$1" ]; then
BRANCH_NAME="$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)" | cut -d '/' -f2)"
else
BRANCH_NAME="$1"
fi
git push origin HEAD:refs/for/$BRANCH_NAME
}
gpgwip() {
if [ -z "$1" ]; then
BRANCH_NAME="$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)" | cut -d '/' -f2)"
else
BRANCH_NAME="$1"
fi
git push origin HEAD:refs/for/$BRANCH_NAME%wip
}
gpgready() {
if [ -z "$1" ]; then
BRANCH_NAME="$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)" | cut -d '/' -f2)"
else
BRANCH_NAME="$1"
fi
git commit --amend --no-edit
git push origin HEAD:refs/for/$BRANCH_NAME%ready
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment