0

Some time ago I made a mistake by merging a feature branch into the master branch (should have been develop). I noticed this just after the merge and did a reset on the master branch. This removed about 10 files from the master branch. Meanwhile I branched a new feature branch from develop and worked on this branch (also on the files deleted from master) and merged it back into develop.

Today I merged the develop branch into master for a new release. Unfortunately all files that were removed during the reset are missing in the master branch, new files that were added later are present.

I would like to merge the develop branch into master so that after the merge the master branch has the same files as the develop branch. How can I do this?

I've tried rebasing the develop branch with the master branch but that only resulted in the files to be removed from the develop branch as wel. I've been able to roll this back

2 Answers 2

1

You can check the git logs and identify the last commit which has all the files that you lost.

git log

Once you identified the commit, copy the hash against the commit and run git checkout command.

git checkout COMMITHASH

after this your head will point to this commit which is having all the deleted files. You can merge your develop branch with current master state.

Note: not recommended according to me.

1
  • Not sure if my history is still correct, but my files are back ;-)
    – Dieudonné
    Commented Aug 6, 2015 at 23:55
1

Do you have these files in the develop branch ? If so, they must be add by commit(s), right? Maybe you can make some patch by using

   git format-patch -s commit 

Save the patch to some other place. The checkout to master branch and apply it by using

   cat patch | git am

Not the answer you're looking for? Browse other questions tagged or ask your own question.