Home > Net >  Complex GIT cleanup
Complex GIT cleanup

Time:09-17

I was working on a big task on a my-branch branch which was create out of develop. In the meantime, I was taking pulls from develop, thinking it was a good one.

After some time the develop branch was renamed to test. Other developers were informed to make tests on the test branch.

I was informed that the develop branch was renamed to test, but I was not informed that I should start taking pulls (to merge) from master.

Then I started taking pulls from master.

Now my-branch has a lot of my work (good one), and a lot of tests - bad ones that should not be merged to master.

I need to:

  • Remove from my-branch all the commits that: are not mine && are not in master

In other words, I need to remove all the commits other did, and those commits were not merged with master. This means those commits were tests/trash.

How to do that?

CodePudding user response:

Perhaps this will work (assuming that your local master/test branches are already up-to-date with the remote ones):

git rebase --onto master test my-branch

This can be read like this: git, please, rebase all revisions that are on my-branch on top of master but make sure to discard all revisions that make up the history of test branch..... thanks!

This should be rebasing only revisions of yours, unless you did something funky.

  • Related