3

Lets say I got a feature that takes me 3 days to complete.

After each day I'd to like backup my data somehow but not pushing commits to main branch since the feature is not complete.

If I do a new branch and commits three times to it and then merge it with main branch you are gonna have an ugly history:

WIP featureA
WIP featureA
Added feature A

Should I squash my three commit messages into one single before I merges? Like this: Squash my last X commits together using Git

Is this the best approach?

Community
  • 1
  • 1
Joe
  • 4,274
  • 32
  • 95
  • 175
  • 1
    That sounds like http://stackoverflow.com/a/34328663/6309 – VonC Dec 20 '15 at 19:37
  • In 3 days if you have 20 commits in your branch and then merge to master, those 20 commits will appear in master. They don't need to look pretty, do they? I personally love to review the progression of a branch. – zedfoxus Dec 20 '15 at 19:39

1 Answers1

0

yep. you can commit as many commits as you wish.

Once you done use the :

git rebase -i HEAD~X

Where X is the number of the commits that you want to combine together. This is called interactive rebase or `squash``

Once you squash your commits - choose the s for squash = it will combine all the commits into a single commit.

enter image description here

CodeWizard
  • 128,036
  • 21
  • 144
  • 167