Skip to content

Instantly share code, notes, and snippets.

@rxx
Created June 4, 2015 08:29
Show Gist options
  • Save rxx/d94b8c40e925b9ebf262 to your computer and use it in GitHub Desktop.
Save rxx/d94b8c40e925b9ebf262 to your computer and use it in GitHub Desktop.
Git diff and apply
You can apply the patch as a 3-way merge:
git diff 13.1_dev sale_edit > patch.diff
git apply -3 patch.diff
It should bring up the conflict so that you can resolve manually. Or you could go with a one-liner, piping the patch to git-apply directly:
git diff 13.1_dev sale_edit | git apply -3
To reverse the patch:
git diff 13.1_dev sale_edit | git apply -3 -R
(note: this is same as the commands above, without the two-stage process of creating the patch file)
git help apply
-3, --3way
When the patch does not apply cleanly, fall back on 3-way merge if
the patch records the identity of blobs it is supposed to apply to,
and we have those blobs available locally, possibly leaving
the conflict markers in the files in the working tree for the user
to resolve...
it diff 13.1_dev sale_edit > patch.diff yourBranch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment