The question arises : “ Git: copy all files to a directory from another branch , which shows how to do this. But it does not delete files that are in the current branch, but deleted from another.
There are several solutions that I usually use:
Delete the directory locally rm -r dir, then execute git checkout otherBranch -- dir. It works, but too slow for large directories.
Do git checkout dirand then git rm $(git diff --name-only otherBranch -- dir). It works, but I believe that this should be the best solution.
Any easier way to do this?
source
share