Git merge specific file from another branch

twitter logo github logo ・1 min read

There are two teams working on the same project and they realize a common problem that was already resolved by one side, but the status of work in each branch is in progress and to make a merge can be unsafe.

How to solve this problem?

There is a safe solution: merge a specific file from another branch. And there is the steps:

$ git checkout <another-branch> <path-to-file> [<one-more-file> ...]
$ git status
$ git commit -m "'Merge' specific file from '<another-branch>'"

That's it!

Here is a more detailed approach.

twitter logo DISCUSS (4)
markdown guide

Was literally JUST talking about this today, thanks!


I'm glad to be able to help this wonderful community!


One of those things I learn today and need to use tomorrow.


this doesn't actually merge the file... it just overwrites it with the version in the another branch!!

Classic DEV Post from May 22

Coding Best Practices, Chapter One: Functions.

Code best practices, how to write readable functions.

Alex Ruzenhack profile image