MiscMisc

How to merge specific files from another branch

Feb 06, 2019 · Updated: Feb 07, 2019 · by Tim Kamanin

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:

shell
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:

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

Not bad, huh?

Hey, if you've found this useful, please share the post to help other folks find it:

There's even more:

Subscribe for updates

  • via Twitter: @timonweb
  • old school RSS:
  • or evergreen email ↓ ↓ ↓