2

我是 Git 的新手,但我一直在学习一些更高级的东西,因为我一直在参与游戏设计比赛。在尝试在两个分支之间拼接更改的过程中,我被介绍到git checkout --patch,这正是我需要的。然而,尽管简单地使用yor应用大块n会起作用,分裂也一样,但每当我选择手动编辑大块时e,它总是失败。以这个补丁为例:

# Manual hunk edit mode -- see bottom for a quick guide
@@ -102,12 +80,12 @@ enum Facing {
     int stunTimer;
     int m_health;

-    bool m_softStun = true;
     bool hitFlag;
     bool jumpFlag;
     SoundGroup contactSounds;

     float movementInput;
+    float verticalInput;

     [SerializeField]
     public GameObject opponent;
# ---
# 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 applying. 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.

这是一个简单的补丁,我可以通过拆分来解决它的问题,但我将使用它作为示例。假设我尝试保留m_softStunbool 和verticalInputfloat 变量。看起来我需要做的就是:

# Manual hunk edit mode -- see bottom for a quick guide
@@ -102,12 +80,12 @@ enum Facing {
     int stunTimer;
     int m_health;

     bool m_softStun = true;
     bool hitFlag;
     bool jumpFlag;
     SoundGroup contactSounds;

     float movementInput;
+    float verticalInput;

     [SerializeField]
     public GameObject opponent;
# ---
# 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 applying. 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.

我所做的就是删除-前面的,bool m_softStun并且正如文档和其他答案告诉我的那样,添加一个空格。

但是,当我尝试应用此补丁时,它返回给我一个错误:

error: patch failed: Assets/Scripts/Fighter.cs:23
error: Assets/Scripts/Fighter.cs: patch does not apply

此错误或具有不同行号的变体已通过以下所有尝试修复它返回给我:

  • 我使用过标准的 Windows 10 Notepad、Notepad++ 甚至 Vim
  • 我已经检查以确保选项卡在开始时没有使用空格,甚至进入 Vim 的十六进制分析以确保它
  • 我尝试从行尾删除并保留回车符
  • 我尝试通过 Vim、Notepad 和 Notepad++ 以 ANSI 和 UTF-8 进行编码
  • 我试过根本编辑补丁,这仍然给我一个错误,让我怀疑它要么是 git 中的错误,要么是我保存文件的方式。

我几乎无计可施,试图找出问题所在,但我没有足够的技术知识来开始找出问题所在。甚至我当地的“git 人”,他提出了诸如十六进制检查之类的建议,也无法提供帮助,并给我发送了一份迄今为止没有任何结果的错误报告。有谁知道为什么我不能制作手动补丁?

4

0 回答 0