When running git add --patch
, it presents a series of "hunks" that can be applied or skipped with y
or n
respectively, along with other options for editing/etc.
On occasion, when working with a lot of files, I have unintentionally marked n
to the last, or only, hunk in a file that I actually intended to mark y
or e
, resulting in me moving on to the next file. In such a case, is there any way when using the patch editor for me to move back 1 hunk to the previous file?
I know that there is a g
option to go to a specific hunk within the same file, but I'm unsure how to arbitrarily move back 1 hunk if the hunk came from a previous file. Is there a way to just go "back" one hunk?
My options in such a case appear to be either to add -p
all changes again (bad, since there may be a lot of files, with a lot of hunks that need to be skipped), or take note of the individual file that I messed up on and patch-add the single file alone (which may also have many hunks needed to be skipped again).