Git - Checkout a specific file or directory from another branch
Sometimes when working with git, you want to merge some features in another branch into the branch you are working on. But a merge will add all the changes. How do you cherry-pick specific files you want?

I notice git has a command named cherry-pick. But this command does not exactly solve what I want to do. The cherry-pick command simply check out a commit, not for specific files.

git-cherry-pick - Apply the changes introduced by some existing commits

Turn out, the git checkout command already has the ability to pick a specific file or directory already.

You can do this with these commands:

$ git checkout feature-branch -- src/js/some-file.js
$ git checkout feature-branch -- src/js/some_dir/

Pretty simple, right?