Question

I worked on branch_A and merged it to branch_B (both are local branches)

  1. Is it a good practice to squash commits in branch_A.
  2. What if I'm going to push branch_A to public repo and my master will fetch it in the future?
Was it helpful?

Solution

Squashing is almost never a good idea. First of all, it is rewriting your history, so if you pushed (published) your changes, you should not squash. Then, squashing is removing logical sequence of your work - it makes more difficult to track why you yourself did one change or another.

Just about the only situation when squashing might be helpful is when you commit without pushing very often (like 20 times a day), but then after few days you have developed new shiny feature and would like to create just one commit that has this feature implemented and publish just that one commit or send it for code review.

OTHER TIPS

  1. Squash and fixup could be a good practice for misspell or compilation fix.
  2. It's a public feature branche? Why not...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top