I’m mid way through a pretty time consuming merge (merging master into my branch) and resolved all the conflicts I need to resolve. However, git is telling me that there are a bunch of conflicts in folders that need to be resolved also.
I want to tell git to just take my branch’s version of everything in those folders and ignore anything from master. I’ve tried:
git checkout –ours path/to/folder
But git rather unhelpfully tells me X files ‘does not have our version’
I don’t understand this because I had thought the command I was typing was telling git ‘I don’t care what the conflicts are – just take my branch’s folder and move on’. So how could it ‘not have our version’?
This seems like it should be pretty basic because the file-based equivalent is simple (merge, take our branch version, take master branch version). I would have hoped an equivalent existed for a folder (i.e. take our branch version of everything in this folder)
I’m very conscious of messing this up and so while this question on SO appears to be asking pretty much the same thing, the answer seems to involve multiple steps and I’m wary of screwing up the whole merge and having to start again.
Suggestions as to how I can accomplish this kind of ‘ignore all conflicts in this folder’ are welcome.
>Solution :
A simple solution would be:
git checkout <COMMIT_HASH> -- path/to/folder
If git log does not give you a usable commit hash because of the merge,
you can get a recent one from git reflog.
If you have new files that were not indexed at that time,
you can delete them using
cd path/to/folder
git clean -fdx
!!! In order to not mess up here and remove stuff you still need, dry-run that command
ahead of time using git clean -ndx