最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

git - Error: "patch does not apply" when manually editing diff - Stack Overflow

programmeradmin1浏览0评论

I have the following git diff for Python code:

@@ -520,7 +520,7 @@ class AreaManager:
         self.broadcast_ooc(
             f"[{client.id}] {client.showname} ({client.name}) is GM in this hub now."
         )
-        #client.hide(True)
+        client.hide(True)
 
     def remove_owner(self, client):
         """

I want to discard changes using git add -i by removing the '+' line and restoring the '-' line. I do it as this:

@@ -520,7 +520,7 @@ class AreaManager:
         self.broadcast_ooc(
             f"[{client.id}] {client.showname} ({client.name}) is GM in this hub now."
         )
         #client.hide(True)
 
     def remove_owner(self, client):
         """

I've read these SO questions as well as this blog post, and kept track of spaces and line count, but Git still produces an error: error: corrupt patch at line 13

How do I make Git apply my changes? What am I missing?

I use Notepad++ v8.4.2 as Git default code editor under Win10 OS.

I have the following git diff for Python code:

@@ -520,7 +520,7 @@ class AreaManager:
         self.broadcast_ooc(
             f"[{client.id}] {client.showname} ({client.name}) is GM in this hub now."
         )
-        #client.hide(True)
+        client.hide(True)
 
     def remove_owner(self, client):
         """

I want to discard changes using git add -i by removing the '+' line and restoring the '-' line. I do it as this:

@@ -520,7 +520,7 @@ class AreaManager:
         self.broadcast_ooc(
             f"[{client.id}] {client.showname} ({client.name}) is GM in this hub now."
         )
         #client.hide(True)
 
     def remove_owner(self, client):
         """

I've read these SO questions as well as this blog post, and kept track of spaces and line count, but Git still produces an error: error: corrupt patch at line 13

How do I make Git apply my changes? What am I missing?

I use Notepad++ v8.4.2 as Git default code editor under Win10 OS.

Share Improve this question edited Jan 24 at 9:30 Guildenstern 3,8982 gold badges28 silver badges53 bronze badges asked Jan 22 at 15:25 user27575278user27575278 93 bronze badges 1
  • there are some long standing bugs related to this kind of patch editing. An alternate way is to open git gui, and use the graphical interface to amend your changes – LeGEC Commented Jan 22 at 15:32
Add a comment  | 

1 Answer 1

Reset to default 0

Thanks @LeGEC for suggesting using git gui, amending changes there solved the problem.

发布评论

评论列表(0)

  1. 暂无评论