I am doing something very simple wrong. I\'m trying to prepare an ordinary patch file, so I can reapply some changes:
$ git diff > before
$ git diff some
If you want to use patch you need to remove the a/
b/
prefixes that git uses by default. You can do this with the --no-prefix
option (you can also do this with patch's -p
option):
git diff --no-prefix []
Usually though, it is easier to use straight git diff
and then use the output to feed to git apply
.
Most of the time I try to avoid using textual patches. Usually one or more of temporary commits combined with rebase, git stash
and bundles are easier to manage.
For your use case I think that stash
is most appropriate.
# save uncommitted changes
git stash
# do a merge or some other operation
git merge some-branch
# re-apply changes, removing stash if successful
# (you may be asked to resolve conflicts).
git stash pop