How to merge specific files from another branch

06 Feb · by Tim Kamanin · 1 min read

Let's say you have a branch dev and in that branch, you have a file graphql.config.json and you want to merge it into your master. How do you do that?

Despite working with git for about ten years, I didn't know about this one until now. And it turned out to be as simple as:

git checkout dev graphql.config.json

Note: You need to be in your target branch while running this command (in master in my case).

What's even cooler, you can merge more than a single file:

git checkout dev graphql.config.json app/fixtures.json bin/sync.sh

Not bad, huh?

Want to get more 🔥 tips like this one?

Subscribe to get notified about new dev tutorials

Comments