I\'m using Git on a new project that has two parallel -- but currently experimental -- development branches:
master
: import of existing codebase pl
The simple way, to actually merge specific files from two branches, not just replace specific files with ones from another branch.
git diff branch_b > my_patch_file.patch
Creates a patch file of the difference between the current branch and branch_b
git apply -p1 --include=pattern/matching/the/path/to/file/or/folder my_patch_file.patch
You can use *
as a wildcard in the include pattern.
Slashes don't need to be escaped.
Also, you could use --exclude instead and apply it to everything except the files matching the pattern, or reverse the patch with -R
The -p1 option is a holdover from the *Unix patch command and the fact that the patch file's contents prepend each file name with a/
or b/
(or more depending on how the patch file was generated) which you need to strip, so that it can figure out the real file to the path to the file the patch needs to be applied to.
Check out the man page for git-apply for more options.
Obviously you'd want to commit your changes, but who's to say you don't have some other related tweaks you want to do before making your commit.