Skip to content

Instantly share code, notes, and snippets.

@kumikoda
Last active June 3, 2017 14:09
Show Gist options
  • Save kumikoda/8660755 to your computer and use it in GitHub Desktop.
Save kumikoda/8660755 to your computer and use it in GitHub Desktop.
squashing your commits
  1. Make sure you have the latest code
git fetch --all 
git log
  1. start rebasing. If you have a feature branch you want to merge, you might rebase off dev. If you simply want to squash a few commits together, you might rebase off of a specific head location.
git rebase -i origin/dev // (rebase off of another branch)
git rebase -i HEAD~5 // (rebase off HEAD @ previous 5 commits) 
  1. Pick your commits that you want to pick or squash. normally you would 'pick' the first, and 'squash' the rest
pick 01d1124 Added hello.js
squash 6340aaa Added some tests
squash ebfd367 Added some logic
squash 30e0ccb Fixed some bugs
  1. Deal with merge conflicts
<fix stuff here>
git add .
git rebase --continue
  1. Squash and summarize your commit messages
Added hello feature
  1. Verify that you have the correct squashed commmit
git log
  1. Force push
git push -f origin my_branch
  1. If at any point you are confused, abort!
git rebase --abort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment