Skip to content

Instantly share code, notes, and snippets.

@dhruv-m-patel
Last active December 20, 2017 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhruv-m-patel/b20dcf4d47be375008e0e2fc413b5786 to your computer and use it in GitHub Desktop.
Save dhruv-m-patel/b20dcf4d47be375008e0e2fc413b5786 to your computer and use it in GitHub Desktop.
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