Ok, so here’s the story. We’ve got git repository with 20-30k lines of code. My workmate copied (copied, not moved) few files in repo to create another module. Content of these files was just slightly modified. Then he made a commit. Meanwhile I worked with some of the files that he copied (the originals) and commited my work. When I was pulling I realized that I’ve got conflicts in files that I didn’t have, since he just created them (copied them). After resolving the conflicts I checked my local repo and I don’t have half of the files I suppose to have. I know git tracks the content of the files, not the file names, but right now it’s not very helpful.
git log remote_repo --stat --diff-filter=D
shows that few files was deleted, and
git log remote_repo --stat -C --diff-filter=D
shows that fewer files was deleted (but still some)
We need both copies of files so what should we do?
You’ll need to rebase and try resolving the conflicts again. This may be simple or slightly more complex. If it is simple you will only nee to rebase the merge and fix the files that were deleted. Try this:
You will be presented with a screen asking what you want to do to each commit.
It will be something like:
Change pick to edit, save and quit the editor. You are now back in the merge commit. Run:
That should fix it. If it doesn’t, you’ll need to go back further and it may be more complex.
I would guess that it would go something like this:
You will be presented with a screen asking what you want to do to each commit.
It will be something like:
Leave the first line as is. Change pick in the second to edit. The last I think you want to edit as well.
Write and save this and the rebase will begin. It will run through the first commit and stop at the second. Your files should be missing. You now want to run:
And that will restore files deleted by your coworker.
Then run:
When you get to the merge commit just check to make sure that things are as you expect. If files are missing try checking them out again. Then amend and continue. You should now have everything you need.
If you feel things are going wrong at any point
This will put you back to where you started and you can try again.