Ok so git diff --name-status branch1..branch2
gives me this:
M .gitignore
M README.md
A README_orig.md
M deps/npm/lib/cache/add-remote-git.js
M deps/npm/lib/fetch-package-metadata.js
M deps/npm/lib/utils/git.js
A git_wrapper.bat
I would like to copy those files (not patches produced by git diff
) from branch2
into a brand new orphan (empty) branch and commit there.
Is there some succint way of achieving that with git or it's git checkout branch2 -- path1
, ...path2
, etc. time?
UPDATE
OK, I see I should have explained the context.
This is a rather unusual situation. I'm packaging some elaborate software for the company (namely, node.js, Visual Studio Code) for the company. This requires a number of customizations reproduced to the same effect on each new version incoming.
Now, the way e.g. Visual Studio Code compilation works is that it does not ship entire source code needed to compile the app. It downloads tons and tons of stuff during compilation process (clones literally dozens or even hundreds of Github repos), regenerates some stuff, etc, while we need to apply our customizations and fixes on top of that downloaded stuff; maintainers of some node modules are unresponsive re fixing the stuff or even applying fixes I worked out and dutifully reported, but we still need to apply those fixes and for obvious reasons do not want to create our forks of those modules that will get stale in time.
I obviously cannot just use usual git diff
to apply our specific fixes and customizations between say v1.12.2acme
and v1.14.0asshippedbymicrosoft
because lots of unrelated files change. Now I guess I could store the changes only in the past fixed/customized branches or tags of the product:
git diff commit_acme_fixed..commit_v1.14.0 -- file1.js
git diff commit_acme_fixed..commit_v1.14.0 -- file2.js
but... I do not really want to do that. My idea is to have unrelated (orphan) acme_customisations
branch where all the files with their versions are stored only for purpose of patching subsequent incoming new releases. I could then create a commit or tag in that branch that will encapsulate cleanly just the changes I need replayed on incoming v1.14.0asshippedbymicrosoft
release as our customizations will surely have to be modified sooner or later given the changes in the base product.
It's also much, much easier for other people to figure out just what files are changed by us among plethora of files changing between versions of the base product (I guess you could find that out by committer, but that's additional filtering at this level you have to do and also the risk you'll miss someone as a committer and lose some changes from sight, while working with 2 branches/tags/commits is much more natural and well-supported by git
).