Skip to content

Instantly share code, notes, and snippets.

@clausti
Last active July 16, 2019 18:37
Show Gist options
  • Save clausti/a41fec65495612141cc75eedb256f1af to your computer and use it in GitHub Desktop.
Save clausti/a41fec65495612141cc75eedb256f1af to your computer and use it in GitHub Desktop.
something for your .bashrc to make updating forks easier
function gitbranch() {
git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,'
}
function gitup() {
local git_branch=$(gitbranch)
local stash_out=$(git stash)
echo $stash_out
git checkout master
git fetch upstream
git merge upstream/master
git push origin master
git checkout $git_branch
if [[ $1 == 'mm' ]]; then
git merge master
fi
if [[ $1 == 'rm' ]]; then
git rebase master
fi
if [[ $2 == 'p' ]]; then
git push origin $git_branch
fi
if [[ $stash_out != 'No local changes to save' ]]; then
git stash pop
fi
}
export -f gitup
Color_Off="\[\033[0m\]" # Text Reset
Yellow="\[\033[0;33m\]"
Cyan="\[\033[0;36m\]"
export PS1="\u@\h $Cyan\W $Yellow\$(gitbranch) $Color_Off$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment