Created
October 21, 2016 07:06
-
-
Save andypotanin/25122962a6ac9689176329fdf1b66ccf to your computer and use it in GitHub Desktop.
Put into a directory that is in $PATH. Then run "git deploy {branch}" to push current branch into it.
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
#!/usr/bin/env bash | |
## Deploy branch into "develop" branch | |
## | |
## Usage: | |
## | |
## git deploy production | |
## | |
## Save Original Branch | |
ORIGINAL_BRANCH=$(git symbolic-ref --short HEAD) | |
PARENT_TARGET=$(git show-branch -a | awk -F'[]^~[]' '/\*/ && !/'"$ORIGINAL_BRANCH"'/ {print $2;exit}'); | |
if [ -n "${1}" ]; then | |
PARENT_BRANCH=${1}; | |
else | |
PARENT_BRANCH=${PARENT_TARGET/origin\//} | |
fi | |
echo "Deploying [${ORIGINAL_BRANCH}] into [${PARENT_BRANCH}]." | |
## Checkout target branch "develop" | |
git checkout ${PARENT_BRANCH} | |
## Pull down develop branch | |
git pull | |
## Merge our original branch into the develop branch | |
git merge origin/$ORIGINAL_BRANCH -m "Deploying [${ORIGINAL_BRANCH}] into [${PARENT_BRANCH}]." | |
## Push to develop | |
git push | |
## Checkout our original branch again | |
git checkout ${ORIGINAL_BRANCH} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment