Created
October 17, 2014 19:10
-
-
Save squarelover/7e5095de0f5866f25eaa to your computer and use it in GitHub Desktop.
Git Aliases that cam make push and pull easier.
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
# | |
# Will return the current branch name | |
# Usage example: git pull origin $(current_branch) | |
# | |
function current_branch() { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || \ | |
ref=$(git rev-parse --short HEAD 2> /dev/null) || return | |
echo ${ref#refs/heads/} | |
} | |
function current_repository() { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || \ | |
ref=$(git rev-parse --short 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 ggpur='git pull --rebase origin $(current_branch)' | |
compdef ggpur=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 | |
# You can replace the origin with an ENV variable, such as $CURRENT_FORK or have it read from a value in .git/config | |
# Let me know if you need more help with building you git tools. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment