Git提交手动编辑hunk

Git提交手动编辑hunk,git,git-commit,Git,Git Commit,因此,我无法正确地为提交添加大块 我有这样的想法: @@ -6,6 +9,5 @@ #include "incfile.h" bool func3(int&, const char*); -int func1(const int, std::vector<std::unique_ptr<type> >&); -void func2(const std::vector<std::unique_ptr<type> >&);

因此,我无法正确地为提交添加大块

我有这样的想法:

@@ -6,6 +9,5 @@
#include "incfile.h"

 bool func3(int&, const char*);
-int func1(const int, std::vector<std::unique_ptr<type> >&);
-void func2(const std::vector<std::unique_ptr<type> >&);
+int func1(const int, std::vector<std::shared_ptr<type> >&);
 void func4(const int);
@-6,6+9,5@@
#包括“incfile.h”
布尔函数3(整数和常量字符*);
-int func1(常数int,std::vector&);
-void func2(const std::vector&);
+int func1(常数int,std::vector&);
无效函数4(常数int);
我试图只阶段性地更改
func2
我希望在diff commit中更改
func1
,我很挣扎,因为每次我删除
-
或行或任何导致补丁不适用的内容。我想我可以简单地从
func1
前面删除
-
,然后删除
+
func1
,这样就可以了,但它不起作用。

这样做:

 int func1(const int, std::vector<std::unique_ptr<type> >&);
-void func2(const std::vector<std::unique_ptr<type> >&);
intfunc1(常量int,std::vector&);
-void func2(const std::vector&);

换句话说,用一个
(空格)替换第一个
-
,并完全删除最后一行。

您可以尝试
git rebase-i…
来设置一系列用于损坏的提交。
-i
(交互式)标志在每次提交时提供的选项之一是对其进行
e
编辑。这会使进程停止,因此您可以在空闲时更改提交(在本例中,编辑修改后的文件以适应口味),然后
git add incfile.h
记录更改,然后
git rebase——继续
重播其他提交


如果你是偏执狂,你可以通过git checkout-b实验来创建一个分支,这样你就不必冒失去它的风险,然后开始新的
实验
分支。

我已经尝试过了,但它仍然说补丁不适用请给出确切的错误。还有,你执行什么命令来暂存文件?你到底是如何暂存文件的?我正在做一个
git add-p文件
,我有3个块,第一个我没有添加,这是第二个,第三个我没有添加。你在第二个块按“e”键?另外,第三块与第二块相关吗?