Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Merging a branch with a reverted change

Here is the situation.

I accidentally committed to master branch which I actually wanted to commit to branch X.
Then I merge master to X then git revert the changes on master.

But eventually this X will be merged to master but then It won’t merge this reverted change.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What is the most proper way to fix this?

>Solution :

Rewrite the history of the branch so that to git, it is like that is work that has never been merged into the branch. Suppose that the branch is 2 commits:

git checkout some-branch~2 # we start from the point where that work was started
git cherry-pick HEAD..some-branch
# that will create 2 new commits with the same stuff as the original 2
# but this is something that has never been merged
git branch something

This branch can be merged into master

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading