Skip to content

Instantly share code, notes, and snippets.

@praveenc
Created April 4, 2020 16:52
Show Gist options
  • Save praveenc/93e63de0db5ad0a47b6e326399fc9ceb to your computer and use it in GitHub Desktop.
Save praveenc/93e63de0db5ad0a47b6e326399fc9ceb to your computer and use it in GitHub Desktop.
Git aliases
#cite 'about-alias'
#about-alias 'common git abbreviations'
# Aliases
alias gcl='git clone'
alias ga='git add'
alias gall='git add .'
alias gus='git reset HEAD'
alias gm="git merge"
alias g='git'
alias get='git'
alias gst='git status'
alias gs='git status'
alias gss='git status -s'
alias gl='git pull'
alias gpr='git pull --rebase'
alias gpp='git pull && git push'
alias gup='git fetch && git rebase'
alias gp='git push'
alias gpo='git push origin'
alias gdv='git diff -w "$@" | vim -R -'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gcmns='git commit -v -m'
alias gcm='git commit -v -S -m'
alias gci='git commit --interactive'
alias gb='git branch'
alias gba='git branch -a'
alias gcount='git shortlog -sn'
alias gcp='git cherry-pick'
alias gco='git checkout'
alias gexport='git archive --format=tar'
alias gdel='git branch -D'
alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master'
alias gls='git log --graph -n 18 --pretty=oneline --abbrev-commit'
alias gll='git log --graph --pretty=oneline --abbrev-commit'
alias gg="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
alias ggs="gg --stat"
alias gsl="git shortlog -sn"
alias gw="git whatchanged"
alias gt="git tag"
alias gta="git tag -a"
alias gtd="git tag -d"
alias gtl="git tag -l"
# From http://blogs.atlassian.com/2014/10/advanced-git-aliases/
# Show commits since last pull
alias gnew="git log HEAD@{1}..HEAD@{0}"
# Add uncommitted and unstaged changes to the last commit
alias gcaa="git commit -a --amend -C HEAD"
case $OSTYPE in
darwin*)
alias gtls="git tag -l | gsort -V"
;;
*)
alias gtls='git tag -l | sort -V'
;;
esac
if [ -z "$EDITOR" ]; then
case $OSTYPE in
linux*)
alias gd='git diff | vim -R -'
;;
darwin*)
alias gd='git diff | code'
;;
*)
alias gd='git diff'
;;
esac
else
alias gd="git diff | $EDITOR"
fi
# git rebase
greb() { git rebase -i HEAD~$1; };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment