Created
April 27, 2017 17:53
-
-
Save andersonba/a5816fc0cc7334d0fc5fadd9d6ca40f9 to your computer and use it in GitHub Desktop.
Git fetch, merge and push in one command
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
#!/usr/bin/env bash | |
MASTER="master" | |
if [[ "$1" != "" ]]; then | |
BRANCH="$1" | |
else | |
BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
fi | |
echo "> Fetching origin/$MASTER..." | |
git fetch origin $MASTER | |
echo "> Merging with $BRANCH" | |
git merge origin/master $BRANCH | |
echo "> Done" | |
read -r -p "Do you want to push this branch? [y/N] " response | |
case "$response" in | |
[yY][eE][sS]|[yY]) | |
echo "> Pushing $BRANCH to origin..." | |
git push origin $BRANCH | |
exit 0 | |
;; | |
*) | |
exit 0 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment