我是Git的新手,但我一直在学习一些更先进的东西,因为我一直在从事游戏设计竞赛。在尝试在两个分支之间拼接变化的过程中,我已经被引入git checkout --patch
,这将完全符合我的需要。但是,尽管简单地应用具有y
或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_softStun
bool和verticalInput
浮点变量。看起来我需要做的就是:
# 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
此错误或具有不同行号的变体已通过以下所有尝试修复它而返回给我:
我实际上在我的脑海里试图弄清楚出了什么问题,但我还没有技术知识甚至没有开始发现。甚至我的本地' git guy',他们建议使用十六进制检查这样的东西也无法提供帮助,并且发送给我发送了一个错误报告,这个报告到目前为止一无所获。 有没有人知道为什么我不能制作手动补丁?