First of all, I've tried to look for this before, but only "How to revert merges" post are shown, so I write this in hope to solve the problem.
What happened:
- I have a branch (Father)
- A job friend made a new branch from father to start working there.
- I start coding and pushed to father branch instead new one some commits (my bad)
- Another person revert commits to solve the problem, so I can push them to the correct branch.
- A month later, we finish working on said branch, and now I need to merge this branch back to father.
The problem:
- When I do the merge, the father reverted commits are being applied, deleting/downgrading part of my job.
Important to know
- Father branch remains untouched (Just the reverts have happened after we create the new branch)
What I need
- Just merging branch to father without loosing part of my already done job. All changes from my branch should remain.
What Ive tried
- Merge father to child (Didnt work, thats the initial problem, it brings reverts and undo job)
- Made some changes to the files which were reverted (on child branch), so update date is newer so they should remain now (Didnt work, only keep deleted files, but the rest is still being undo)
- Merge child to father (Didnt work, reverted commits are still aplying)
What may solve the problem but doesnt look like a good option
- Cherry pick, one by one, all commits from child to father (61 commits including some merges from other branches from child)
- Copy files that could be reverted, merge, paste files back, commit and push (I dont even think this should be a option, but still, may work)
Don't know what else to do or how to solve this problem correctly.
We need to deploy the app to production soon, and need to fix this issue in order to do that.
A-B-C-D-E-F-Dr-Er-Fr (Branch A)
\
D-E-F-G-H-I.... (Branch B)
Dr, Er, Fr are the reverted commits
As you can see, they're added in the new branch, but have the same date as branch A, because after reverting, I reseted the Branch A so I have the changes staged. Checked out Branch B, and committed/pushed changes here.
I finally was able to fix it, and was mostly easy.
Just neded to revert the reverted commits and push the changes. Now I'm able to merge my branch normally.
Reading what matt said on first place gave a good point of view to. That problem was about reverting a merge already pushed (Not exactly my case) but was a really helpful reading, can recommend it to everyone.
https://github.com/git/git/blob/master/Documentation/howto/revert-a-faulty-merge.txt