Skip to content

Instantly share code, notes, and snippets.

@bradtheappguy
Created January 14, 2020 22:26
Show Gist options
  • Select an option

  • Save bradtheappguy/e5be37e015ced9640efc7b53bf81dc7e to your computer and use it in GitHub Desktop.

Select an option

Save bradtheappguy/e5be37e015ced9640efc7b53bf81dc7e to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
[ $# -eq 0 ] && {
echo "Usage: $0 new_branch_name \"Your commit message\"";
echo " -Stashes local changes.
-Creates new branch.
-Adds and commits all changes
-Pushes to github and creates branch
-Switches back to original branch
-Deletes PR branch"
exit 1;
}
WORKING_BRANCH=$1
MESSAGE=$2
STARTING_BRANCH=`git rev-parse --abbrev-ref HEAD`
git stash
git checkout -b "${WORKING_BRANCH}"
git stash apply
git add -A
git commit -m"${MESSAGE}"
git push
hub pull-request -m "${MESSAGE}"
git checkout "${STARTING_BRANCH}"
git branch -D "${WORKING_BRANCH}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment