Skip to content

Instantly share code, notes, and snippets.

@wesleyegberto
Created July 9, 2018 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wesleyegberto/8d524874cd09e2f4dd100d0f6b5c23d4 to your computer and use it in GitHub Desktop.
Save wesleyegberto/8d524874cd09e2f4dd100d0f6b5c23d4 to your computer and use it in GitHub Desktop.
Example of script to automatically stash updates, checkout and merge a branch and then commit the changes
#!/bin/bash
set -o errexit # Exit on error
git stash save 'Before deploy' # Stash all changes before deploy
git checkout deploy
git merge master --no-edit # Merge in the master branch without prompting
npm run build # Generate the bundled Javascript and CSS
if $(git commit -am Deploy); then # Commit the changes, if any
echo 'Changes Committed'
fi
git push heroku deploy:master # Deploy to Heroku
git checkout master # Checkout master again
git stash pop # And restore the changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment