There's another way to do this that doesn't require the patch file at all.
The problem happened going from A
to B
, so first revert the changes in B
but don't automatically commit.
$ git revert --no-commit <commit hash of B>
The changes that git revert
would do are staged. Unstage them.
$ git reset HEAD
Next, interactively go through file.txt
and stage only the changes you want to keep.
$ git add --patch file.txt
Only the reverts you selected are now staged. Commit them.
$ git commit
Finally, clean up the unstaged leftovers from git revert
.
$ git reset --hard