Cherry-picking with git could easily become a nightmare if some files are renamed or the directory structure of the project is changed. In these cases, it is often helpful to cherry-pick the problematic files individually.
Fortunately, this can be done in a few easy steps:
- Create a patch file for that individual file:
git show [commit hash] -- path/to/old/file > patchfile
- Manually edit the newly created
patchfileand replace all occurrences of the old path with the new path.
- Apply the patch via
git apply --3way patchfile
--3way argument is very important and would tell git to do a 3-way comparison. After step 3, if git is unable to figure out how to merge the changes, it will add conflict markers to the resulting file and would allow one to manually resolve the conflicts.
The procedure above can be repeated for every individual file.