How do I avoid "error: patch fragment without header at line X" for the following hunk when manually editing hunks in Git?

Viewed 2742

I am running Git version 2.18.0.windows.1 and trying to manually edit hunks (this is my first time messing with this). I started by splitting a larger hunk and this is the first of the two hunks. I went to edit the first hunk as follows...

Old Hunk:

@@ -1,8 +1,8 @@
 Shopping List

-apples
-bananas
-yogurt
-milk
+red apples
+6 bananas
+vanilla yogurt
+2% milk
 wheat bread
 cereal

Attempted Edits:

@@ -1,8 +1,8 @@
 Shopping List

 apples
-bananas
+6 bananas
 yogurt
-milk
+2% milk
 wheat bread
 cereal

...but when I save and close my text editor (Atom) Git gives me the following error message:

error: patch fragment without header at line 16: @@ -7,6 +7,6 @@

The line numbers in the error message correspond to the line numbers of my second hunk so I'm guessing that since I changed the line numbers when editing the first hunk then it must have screwed with the line numbers for the second hunk. The odd part is that I'm following a course and the instructor doesn't seem to have an issue. Is this a potential bug in the version of Git that I'm running or am I missing something?

NOTE: I made sure that there are proper spaces/+/- in front of each line and attempted to modify the line numbers when editing the first hunk but to no avail.

0 Answers
Related