Skip to content

Instantly share code, notes, and snippets.

@JasonMorgan
Created September 20, 2019 13:34
Show Gist options
  • Save JasonMorgan/4940938f687550231d2f8797087489d2 to your computer and use it in GitHub Desktop.
Save JasonMorgan/4940938f687550231d2f8797087489d2 to your computer and use it in GitHub Desktop.
## Bring your current branch up-to-date with master, and squash all your working commits
## commit any working changes on branch "${BRANCH}", then...
## rename the branch to reflect it has the unsquashed commits
git branch -m ${BRANCH}-unsquashed
## crete a new local branch to start with the latest version of master
git checkout master
git pull
git checkout -b ${BRANCH}
## squash in your working commits
git merge --squash ${BRANCH}-unsquashed
## commit the changes, opening your editor to provide a good commit message
## describing the work you were doing
git commit -a
## push the new branch to the your remote, force only if you've previously
## pushed some of the squashed commits and know you won't overwrite anyone's
## work
git push --set-upstream ${REMOTE} ${BRANCH} --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment