-
-
Save saxenanurag/53755e82730407cb019db53f629af114 to your computer and use it in GitHub Desktop.
oh-my-zsh git alias
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
# Aliases | |
alias g='git' | |
alias gst='git status' | |
alias gl='git pull' | |
alias gup='git fetch && git rebase' | |
alias gp='git push' | |
alias gc='git commit -v' | |
alias gca='git commit -v -a' | |
alias gco='git checkout' | |
alias gcm='git checkout master' | |
alias gb='git branch' | |
alias gba='git branch -a' | |
alias gcount='git shortlog -sn' | |
alias gcp='git cherry-pick' | |
alias glg='git log --stat --max-count=5' | |
alias glgg='git log --graph --max-count=5' | |
alias gss='git status -s' | |
alias ga='git add' | |
alias gm='git merge' | |
alias grh='git reset HEAD' | |
alias grhh='git reset HEAD --hard | |
# | |
# Will return the current branch name | |
# Usage example: git pull origin $(current_branch) | |
# | |
function current_branch() { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo ${ref#refs/heads/} | |
} | |
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 | |
alias ggpull='git pull origin $(current_branch)' | |
compdef ggpull=git | |
alias ggpush='git push origin $(current_branch)' | |
compdef ggpush=git | |
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)' | |
compdef ggpnp=git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment