There is a question "Git: copy all files in a directory from another branch" which shows how. But it doesn't delete files that are in the current branch, but that are deleted in the other branch.
There are few solutions I usually use:
Delete the directory locally
rm -r dir
, then dogit checkout otherBranch -- dir
. It works, but is slow for large directories.git checkout dir
and thengit rm $(git diff --name-only otherBranch -- dir)
. It works, but I think there should be a better solution.
Is there an easier way to do it?