In our organization we git rebase
our branches. We rebase onto master
periodically to keep things up-to-date, and git push --force-with-lease
, then let any other devs know.
Developer A was working with Developer B on a branch. Developer B rebased onto master and force-pushed the branch.
Developer A made a mistake and continued working, and when he tried to push, it looks like he got a conflict and merged the rebased branch into his local, then pushed.
No one noticed, and he did it again a few days later.
So now the git history contains the same commits two or three times, and is a disaster to rebase onto master
.
Is there a way to solve this?
Would it be best to make a new branch off master
and cherry-pick the non-duplicate commits? Does it matter which commit gets cherry-picked, in the case of duplicates?