Trying to learn best practices for git when working in a team.
When is good to use rebase
and when to use squash
and when is NOT good to use them? (scenarios description/examples would be great to illustrate)
Trying to learn best practices for git when working in a team.
When is good to use rebase
and when to use squash
and when is NOT good to use them? (scenarios description/examples would be great to illustrate)
When not to use them: If you are afraid of changing the git history, and potentially, losing changes.
When to use: In order to keep a consistent flat history with on-point messages.
wip templates
, wip logic
, wip
-- you then can combine all those intermedient commits into one big commit through squash and create a decent message for them.I don't squash manually anymore as most decent web clients (e.g. bitbucket, github) allow for squash merging strategy for Pull Requests.
Both rebase and squashing change the history and should therfore only be used on feature branches owned by one developer. Your main branch should and any public branch should stay as they are.
(You may allow always for pull --rebase
instead of pull
as that only changes the history of your local repository.)