I have a ‘master’ branch and several topic branches. Assume that the master branch is used primarily as a release candidate and no development work happens on this branch.
The topic branches are several and are shared by the team. Some of the branches have more than one developer working on them. All topic branches are rebased from the master branch regularly.
To clean up the history in the ‘master’ branch, I did a ‘git merge –squash’ when merging code from topic to master branches. This worked perfectly fine.
Now – when topic branches are rebased — the commits are getting duplicated. Is there a way to clean up the commits on the topic branches after the ‘git merge –squash’ has been successful?
Lets assume you have the following scenario:
If you merge topic into master with –squash you will get something like
Where F contains all changes from D and E. Rebasing topic on master makes no sense since the topic branch is already in master (through F). Instead of rebasing you could move the topic branch to F, e.g.
Which yields:
All you need to do now is to push up the moved topic branch: