Skip to content

Instantly share code, notes, and snippets.

@burin
Last active October 26, 2017 18:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save burin/ab156df44fd313bb1b0a to your computer and use it in GitHub Desktop.
Save burin/ab156df44fd313bb1b0a to your computer and use it in GitHub Desktop.
Squashing your commits into one commit without using interactive rebase.

Squashing your commits into one commit without using interactive rebase (https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request#squash-your-changes)

This basically takes the diff of your branch + origin/master and sets them aside for you to "recommit" them.

git fetch -ap # get in sync w/ server
git checkout jscs-disallow-redundant-spaces # switch to the appropriate branch
git reset --hard origin/jscs-disallow-redundant-spaces # get my branch to be exactly the same as what's on the server
MERGE_BASE=$(git merge-base origin/jscs-disallow-redundant-spaces origin/master) # get the commit where your branch originates
git reset --mixed $MERGE_BASE # reset to the point where your branch originates, but put your changes like you just made them
git add . # stage your changes for a new commit
git commit -m 'Disallow spaces between brackets' # commit your new commit
git push origin jscs-disallow-redundant-spaces -f # force push it up to the server. you are rewriting history (check that everything looks ok before doing this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment