Reputation: 7640
I explain the problem
Here is my actual git
I have a problem mergin, the file reverted in the red branch are ignored during the merge with the blue branch4.
Basically, we started working on a feature on red branch, then decided to change branch, and to make red branch "pure" without bug we reverted the initial changes for the feature.
We kept working on the feature on blue branch, based on what we were already doing on the red branch.
There is many file renaming/deletion, and changes.
Now, when I merge blue and red, half of the change are not kept, and there is not even conflicts.
I have made another banch (let s call it purple) with EXACTLY what we want, and I would like to know it there is a way to push the purple branch in the red branch, to keep exactly what is in the purple branch
Upvotes: 1
Views: 262
Reputation: 24194
Fix red
branch (history will not be changed): One way is to revert revert-commit-1
& revert-commit-2
then merge blue
branch into red
branch.
$ git checkout red # checkout to 'red' branch
$ git log # copy the 'revert-commit-2' & 'revert-commit-1' commit hash
$ git revert <revert-commit-2-hash>
$ git revert <revert-commit-1-hash>
$ git pull origin blue # merge the blue branch changes
Another way: Replace current red
branch with purple
branch (red
branch history will be changed)
# first backup the 'red' branch for just safety
$ git checkout red
$ git branch red.bac
# replace red branch with purple branch
$ git checkout purple
$ git branch -D red # delete 'red' branch
$ git checkout -b red # create & checkout to new local 'red' branch with 'purple' branch history
# now if you pushed the 'red' branch already then you need to do force (-f) push otherwise do normal push
$ git push -f origin red
Upvotes: 1