我尝试git add --patch
使用交互式 git add 进行编辑。
所以首先然后git add -i
是编辑补丁(我用vscode而不是vim为编辑器设置了我的设置)What for>p
e
# Manual hunk edit mode -- see bottom for a quick guide.
@@ -1,5 +1,16 @@
import React from "react";
+export type Question = {
+ category: string;
+ correct_answer: string;
+ difficulty: string;
+ incorrect_answers: string[];
+ question: string[];
+ type: string[];
+};
+
+export type QuestionState = Question & { answer: string[] };
+
export enum Difficulty {
EASY = "easy",
MEDIUM = "medium",
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove '+' lines, delete them.
# Lines starting with # will be removed.
#
# If the patch applies cleanly, the edited hunk will immediately be
# marked for staging.
# If it does not apply cleanly, you will be given an opportunity to
# edit again. If all lines of the hunk are removed, then the edit is
# aborted and the hunk is left unchanged.
所以我试图编辑我的补丁(用于分割代码块),我想要的是export type QuestionState = Question & { answer: string[] };
从我的提交中排除。(因为我只想提交导出类型的问题)
但是当我删除时export type QuestionState = Question & { answer: string[] };
(如编辑器中的以下代码)
并保存并退出编辑器(使用快捷键 cmd+w)。
# Manual hunk edit mode -- see bottom for a quick guide.
@@ -1,5 +1,16 @@
import React from "react";
+export type Question = {
+ category: string;
+ correct_answer: string;
+ difficulty: string;
+ incorrect_answers: string[];
+ question: string[];
+ type: string[];
+};
export enum Difficulty {
EASY = "easy",
MEDIUM = "medium",
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove '+' lines, delete them.
# Lines starting with # will be removed.
#
# If the patch applies cleanly, the edited hunk will immediately be
# marked for staging.
# If it does not apply cleanly, you will be given an opportunity to
# edit again. If all lines of the hunk are removed, then the edit is
# aborted and the hunk is left unchanged.
我收到这样的错误
error: patch failed: react-quiz/src/API.ts:1
error: react-quiz/src/API.ts: patch does not apply
Your edited hunk does not apply. Edit again (saying "no" discards!) [y/n]? Your edited hunk does not apply. Edit again (saying "no" discards!) [y/n]? Your edited hunk does not apply. Edit again (saying "no" discards!) [y/n]? y
如何应用编辑补丁?我不知道是什么问题。