1

I've made a merge a month ago on a repo, then reverted it.

Now it causes me trouble when merging because when I try to merge it deletes some files that has been deleted in the revert, but now I need them. And since the commits that deletes them is more recent than the commit that add them, git delete this files when merging

How can I revert a commit from a month ago that looks like this:

... > merge > revert merge (to delete) > other commit to keep > to keep > to keep > ...

To this:

... > merge > other commit to keep > to keep > to keep > ...

Thanks!

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Architek
  • 53
  • 5

1 Answers1

0

Now it causes me trouble when merging because when I try to merge, this merge deletes some files that has been deleted in the revert, but now I need them

After merging source code, system has been deleted some files: the commit deleting these files is more recently.

To resolve the issue, first, you need to find the commit that you want to revert. I think that you only revert some files in that commit. You use:

git revert --no-commit <commit-hash>

By default, the reverting changes would be directly committed by Git. With the "--no-commit" option, the changes will only be created, but not committed. You could then edit them further and commit them manually.

You may encounter a conflict source code when you do this action. Please discard unrelated files.

Thân LƯƠNG Đình
  • 3,082
  • 2
  • 11
  • 21