The easiest way to copy files and folders from within a working tree is to use the right-drag menu. When you right-drag a file or folder from one working tree to another, or even within the same folder, a context menu appears when you release the mouse.
As you are not trying to move the files around in the tree, you should be able to just checkout the directory:
git checkout master -- dirname
If there are no spaces in paths, and you are interested, like I was, in files of specific extension only, you can use
git checkout otherBranch -- $(git ls-tree --name-only -r otherBranch | egrep '*.java')
To copy the directory without tracking it:
git restore --source master dirname
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With