Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active January 27, 2022 21:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/dd264e10b1e2c2388a6a to your computer and use it in GitHub Desktop.
Save westonruter/dd264e10b1e2c2388a6a to your computer and use it in GitHub Desktop.
#!/bin/bash
# preview-branch.sh: Merge the current branch into the preview branch, push, and return to the original branch.
set -e
current_branch=$( git rev-parse --abbrev-ref HEAD )
if [ 'preview' == "$current_branch" ]; then
echo "Oops. You're already on the preview branch. Do you get merge conflicts?"
exit 1
fi
git checkout preview
git pull origin preview
git merge "$current_branch" --no-edit
git push -u origin preview
git checkout "$current_branch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment