Last active
November 29, 2021 22:44
-
-
Save OneOfOne/675a8bdf60608fcd76401d93696cc4ec to your computer and use it in GitHub Desktop.
git-push-new a little git helper to push a new branch and create a pull request.
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
#!/bin/bash | |
BRANCH=$(git symbolic-ref --short HEAD) | |
if echo $BRANCH | grep -q master; then | |
echo no master pushing | |
exit 1 | |
fi | |
args="" | |
nopr=0 | |
for arg in "$@"; do | |
if [ "$arg" == "--nopr" ]; then | |
nopr=1 | |
else | |
args="$args $arg" | |
fi | |
done | |
if git remote show -n origin | grep -q $BRANCH; then | |
git push "$args" || exit 1 | |
else | |
echo creating new branch | |
git push --set-upstream origin $BRANCH $args || exit 1 | |
fi | |
[ "$nopr" == "0" ] && hub pull-request -o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment