Using Finder to copy files by value instead of the files’ reference

copy/pastefindergit

I want to copy a few files from one directory of a git repository branch to another branch that doesn't have the files. With Windows, you can copy the files and they are saved to the clipboard as they are, such as passing the actual files to some temporary directory. This allows you to delete the original files and still paste them elsewhere; basically a cut operation. I know Mac OS doesn't have the ability to cut files, so I assume that is why when I copy files from branch A, checkout branch B, and try to paste the files to the same directory for branch B, the paste option is grayed out; the files that were being referenced no longer exist to be copied.

Is there a way to enable a temporary directory where all copied items aren't simply references to the items that are being copied?

Best Answer

The git-checkout command is used to "checkout" files into your current branch from another branch. This would be safest since it would all remain in version control:

git checkout <branch_name> -- <paths>

Example,

git checkout develop
git checkout master
git checkout develop -- myfile.js

would checkout myfile.js from develop into master so you can commit it when ready.