The git diff
command (with the --no-index
flag) works incredibly well to diff two files, irrespective of whether or not these two files are contained in a Git repo or not.
Example
$ git diff --no-index -- filea fileb
// shows diff between filea and fileb
Question
Is it also possible to use Git to selectively "merge" (i.e. git add
) content from one file to another if they are not part of a Git repo? Basically like a git add -p
but not from the working directory to the index, but from fileb
to filea
.
I feel like all the basic building blocks (plumbing commands) should be available. Possibly something involving format-patch
and/or apply
?
$ <command> filea fileb
// wanted: interactively choose patches/hunks from fileb and apply them to filea