VSCode Git 退出并保存提交编辑器?

Lar*_*ryN 4 git visual-studio-code

我在 Windows 10 上安装了 Git Bash,我正在关注这个关于在 VSCode 中使用 git 的视频https://youtu.be/MIFQwHlEI9o?t=602,他使用带 -p 选项的 checkout 从提交中挑选片段:

$ git checkout 0903304 index.html -p
diff --git b/index.html a/index.html
index 3ebbb46..d95bb1a 100644
--- b/index.html
+++ a/index.html
@@ -10,6 +10,10 @@
     <ul>
         <li>Item one</li>
     </ul>
+
+    <p>Paragraph one</p>
+    <h1>A title</h1>
+    <div><p>Some text</p></div>

 </body>
 </html>
\ No newline at end of file
Apply this hunk to index and worktree [y,n,q,a,d,e,?]
Run Code Online (Sandbox Code Playgroud)

当我输入“e”时,文件会加载两个版本,并且我的光标会自动放置在编辑器中。进行更改并按 CTRL+S 保存后,我无法退出。我尝试过 q、ESC、CTRL+X、wq、:wq、:x!除了用“x”关闭文件之外没有任何作用,但我得到:

Your edited hunk does not apply. Edit again (saying "no" discards!) [y/n]?       0 [sig] bash 987! sigpacket::process: Suppressing signal 18 to win32 process (pid 6340)
Run Code Online (Sandbox Code Playgroud)

Lar*_*ryN 8

我终于弄清楚了这一点,我遵循了 Microsoft Git patch/diff 模式指南https://vscode-docs.readthedocs.io/en/latest/editor/versioncontrol/以及此 stackoverflow 帖子来正确编辑块:git add - -interactive“您编辑的块不适用” 然后在编辑补丁时使用以下内容:

  1. 将文件与任何其他文件一样保存CTRL+S
  2. CTRL+WENTER进行更改后退出并返回到终端