Created
October 16, 2015 05:56
-
-
Save hammeiam/0b1df995d4514aec00fe 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 Push Upstream | |
# A quick command for people that create a lot of feature branches | |
# | |
# Whereas `git push` will return an error if you haven't set the upstream branch | |
# `gpu` will automatically push to the correct upstream branch | |
# so you don't have to type `git push --set-upstream origin my_branch` for each new branch | |
function gpu() { | |
local RESPONSE=$( git push 2>&1 ) | |
local UPSTREAM=$( echo "$RESPONSE" | grep -o "git push --set-upstream origin.*" ) | |
# if we are given an upstream branch, push to that | |
if [ -n "$UPSTREAM" ]; then | |
echo "$UPSTREAM" | |
$UPSTREAM | |
else | |
# won't show the full "counting objects...delta compression...writing objects" response | |
echo "$RESPONSE" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment