Skip to content

Instantly share code, notes, and snippets.

@ob-ivan
Last active January 25, 2024 06:56
Show Gist options
  • Save ob-ivan/5ad1168a4839d9bb9f4ec99c7d0ea949 to your computer and use it in GitHub Desktop.
Save ob-ivan/5ad1168a4839d9bb9f4ec99c7d0ea949 to your computer and use it in GitHub Desktop.
My aliases for git command line
#
# git aliases
#
# USAGE:
#
# $ mkdir ~/github
# $ cd ~/github
# $ git clone [email protected]:5ad1168a4839d9bb9f4ec99c7d0ea949.git gitaliases
#
# Then add these lines to your .bashrc:
#
# GITALIASES="$HOME/github/gitaliases/.gitaliases"
# [[ -f $GITALIASES ]] && . $GITALIASES
#
# Reload .bashrc or relogin, and it works!
#
gbau()
{
git branch --format='%(HEAD),%(refname:short),%(authorname)' --sort=v:refname | awk -F, '{ printf "%s %-70s %s\n", $1, $2, $3 }'
}
gbl()
{
PATTERN='*'"$1"'*'
git branch --list "${PATTERN}"
}
grbx()
{
CONFIG_PATH="${HOME}/.config/grbx.conf"
if test ! -f "${CONFIG_PATH}"
then
echo "Please add a config file at '${CONFIG_PATH}'!"
return 1
fi
EXECUTE_COMMAND=$(cat -- "${CONFIG_PATH}")
git rebase -x"${EXECUTE_COMMAND}" $@
}
alias ga='git add'
alias ga.='git add .'
alias gama='git am --abort'
alias gamc='git am --continue'
alias gamr='git am --reject'
alias gams='git am --skip'
alias gamscp='git am --show-current-patch'
alias gb='git branch --sort=v:refname'
alias gba='git branch -a --sort=v:refname'
alias gbd='git branch -d'
alias gbD='git branch -D'
alias gbf='git branch -f'
alias gbm='git branch -m'
alias gbu='git branch -u'
alias gbuu='git branch --unset-upstream'
alias gbb='git bisect bad'
alias gbg='git bisect good'
alias gbr='git bisect reset'
alias gbs='git bisect start'
alias gcf='git cat-file'
alias gcfp='git cat-file -p'
alias gcft='git cat-file -t'
alias gch='git checkout'
alias gchb='git checkout -b'
alias gcht='git checkout --track'
alias gci='git commit'
alias gcif='git commit --fixup'
alias gcm='git commit -m'
alias gcv='git commit -v'
alias gcva='git commit -v --amend'
alias gcvar='git commit -v --amend --reset-author'
alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
alias gcpn='git cherry-pick --no-commit'
alias gcps='git cherry-pick --skip'
alias gd='git diff'
alias gdc='git diff --cached'
alias gdcw='git diff --cached -w --color-moved-ws=ignore-all-space'
alias gdcwd='git diff --cached -w --color-moved-ws=ignore-all-space --word-diff=color'
alias gdmp='git diff master... >patch'
alias gdni='git diff --no-index'
alias gdno='git diff --name-only'
alias gds='git diff --stat'
alias gdt='git diff --text'
alias gdw='git diff -w --color-moved-ws=ignore-all-space'
alias gdwd='git diff -w --color-moved-ws=ignore-all-space --word-diff=color'
alias gf='git fetch'
alias gfal='git fetch --all'
alias gfp='git fetch --prune'
alias gl='git log --graph --author-date-order'
alias gl1='git log --graph --author-date-order --oneline'
alias gl1a='git log --graph --author-date-order --oneline --all'
alias gl1b='git log --graph --author-date-order --oneline --branches'
alias gl1bm='git log --graph --author-date-order --oneline --branches ^master^'
alias gl1p='git log --oneline --patch'
alias gl1r='git log --oneline --reverse'
alias gl1rp='git log --oneline --reverse --patch'
alias gl1rs='git log --oneline --reverse --no-patch'
alias gla='git log --graph --author-date-order --all'
alias glb='git log --graph --author-date-order --branches'
alias glp='git log --graph --author-date-order --patch'
alias glpw='git log --graph --author-date-order --patch -w --color-moved-ws=ignore-all-space'
alias glr='git log --reverse'
alias glrp='git log --reverse --patch'
alias glrs='git log --reverse --no-patch'
#alias gls='git log --graph --stat' # conflicts with 'gnu ls' for macosx
alias gm='git merge'
alias gma='git merge --abort'
alias gmff='git merge --ff'
alias gmnf='git merge --no-ff'
alias gpl='git pull'
alias gps='git push'
alias gpsf='git push --force-with-lease'
alias gpsfnv='git push --force-with-lease --no-verify'
alias gpsft='git push --follow-tags'
alias gpsnv='git push --no-verify'
alias gpst='git push --tags'
alias gpsu='git push -u'
alias gpsunv='git push -u --no-verify'
alias grb='git rebase'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
alias grbet='git rebase --edit-todo'
alias grbs='git rebase --skip'
alias grbi='git rebase -i'
alias grbr='git rebase -r'
alias grbri='git rebase -ri'
alias grpo='git remote prune origin'
alias grrr='git rerere'
alias grrrf='git rerere forget'
alias grv='git revert'
alias grva='git revert --abort'
alias grvc='git revert --continue'
alias gscp='git rebase --show-current-patch'
alias gsh='git stash'
alias gsha='git stash apply'
alias gshd='git stash drop'
alias gshk='git stash -k'
alias gshl='git stash list'
alias gshlp='git stash list -p'
alias gshp='git stash pop'
alias gshw='git stash show'
alias gst='git status'
alias gsv='git status -vv'
alias gsw='git show'
alias gt='git tag'
alias gta='git tag -a'
alias gtd='git tag -d'
alias gtl='git tag -l --sort=v:refname'
alias gtm='git tag -m'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment