Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Squash commits, split them and make it a story

Say you have 12 commits on a few files for a branch that has not been reviewed yet

Here is a way to make it look like a better, cleaner story:

Step1: Squash commits into single commit

$ git rebase -i HEAD~12 #number of commits you have on your branch
# In editor window, replace all `pick` options for commits with `squash` or `s`
# Hit escape and write `:wq` and hit enter

Step2: Split the commit into meaningful story points:

git reset HEAD^ # will unstage all files you have in one commit
git add filename
git commit -m message
git add filename
git commit -m message
git push -f #you need to force-push as branch was rebased, history is rewritten
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment