Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git revert merge when merged back is deleting files

Tags:

git

Following are the branches in concern inn my project repo:

release/0.1.2 (012)
release/0.2.0 (020)

Following actions happened:

  1. Merge from 020 branches to 012 branch added some new files.

  2. That merge was reverted which therefore deleted some files.

  3. Some other commits were added in 012

PROBLEM:

But now when I am trying to merge 012 to 020, this merge is trying to delete the files in 020 (the ones which were deleted in 012 by the revert). These files are not expected to be deleted in 020.

Since the revert technically deleted the files, this merge is also trying to delete the file (assuming this to be a change).

Is there a way to achieve this merge which won't delete these files without manually saving those files (etc).

like image 305
Shekhar Avatar asked Sep 05 '25 03:09

Shekhar


1 Answers

Merge with --no-commit, meaning to do the merge but not commit it. Then you can undo the deleted files with git restore. Once you've altered the merge to your liking, commit it.

like image 149
Schwern Avatar answered Sep 07 '25 17:09

Schwern