Last active
November 22, 2020 14:33
-
-
Save seanonthenet/4b9046767f3c82fc5dedd7e56385bc0b to your computer and use it in GitHub Desktop.
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
# Git Aliases | |
alias g='git' | |
compdef g=git | |
## Status | |
alias gs='git status' | |
compdef _git gst=git-status | |
alias gss='git status -s' | |
compdef _git gss=git-status | |
## Add and Commit | |
alias ga='git add' | |
compdef _git ga=git-add | |
alias gc='git commit -v' | |
compdef _git gc=git-commit | |
alias gac='git commit -v -a' | |
compdef _git gca=git-commit | |
alias gacw='git commit -v -a -m"WIP"' | |
compdef _git gcaw=git-commit | |
alias gacwp='git commit -v -a -m"WIP" && git push' | |
compdef _git gcawp=git-commit | |
## Push, Pull, Fetch | |
alias gps='git push' | |
compdef _git gps=git-push | |
alias gpl='git pull' | |
compdef _git gpl=git-pull | |
alias gf='git fetch' | |
compdef _git gf=git-fetch | |
alias gup='git fetch && git rebase' | |
compdef _git gup=git-fetch | |
## Branches | |
alias gb='git branch' | |
compdef _git gb=git-branch | |
alias gba='git branch -a' | |
compdef _git gba=git-branch | |
## Checkout | |
alias gco='git checkout' | |
compdef _git gco=git-checkout | |
alias gcom='git checkout master' | |
compdef _git gcom=git-checkout-master | |
## Log | |
alias gl='git log --stat --max-count=5' | |
compdef _git gl=git-log | |
alias glg='git log --graph --max-count=5' | |
compdef _git glg=git-log | |
alias glp="git log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" | |
compdef _git glp=git-log | |
alias glgp='git log --graph --oneline --all --decorate --topo-order --pretty="format:%C(auto)%h%d %s %C(bold blue)<%an>"' | |
compdef _git glgp=git-log | |
alias gcount='git shortlog -sn' | |
compdef gcount=git | |
## Diff | |
gdv() { git diff -w "$@" | view - } | |
compdef _git gdv=git-diff | |
## Merge and Cherry Pick | |
alias gm='git merge' | |
compdef _git gm=git-merge | |
alias gcp='git cherry-pick' | |
compdef _git gcp=git-cherry-pick | |
## Reset Head | |
alias grh='git reset HEAD' | |
alias grhh='git reset HEAD --hard' | |
########################################################################### | |
## Will return the current branch name | |
function current_branch() { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo ${ref#refs/heads/} | |
} | |
## Will return the current repo name | |
function current_repository() { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo $(git remote -v | cut -d':' -f 2) | |
} | |
## these aliases take advantage of the previous function | |
## Pull Origin Current Branch | |
alias gplcb='git pull origin $(current_branch)' | |
compdef gpucb=git | |
## Push Origin Current Branch | |
alias gpscb='git push origin $(current_branch)' | |
compdef gpscb=git | |
## Pull Origin Current Branch && Push Origin Current Branch | |
alias gppcb='git pull origin $(current_branch) && git push origin $(current_branch)' | |
compdef gppcb=git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment