使用 "git format-patch origin/master --stdout" 创建的空补丁

Empty patch created using "git format-patch origin/master --stdout"

我正在研究 create a patch 的 Drill(开源 github 项目)文档。

我遇到了这个命令:

git format-patch origin/master --stdout > DRILL-1234.1.patch.txt

我做了一些修改。我通过 git status 验证了我的更改。我修改了一个.java文件。我试过上面提到的命令来创建一个补丁。

我打开了 DRILL-1234.1.patch.txt 并且它的 是空的

然后我尝试了 git add <modified file> 并尝试了相同的命令,仍然是 补丁文件。

我错过了什么?

Git format-patch 从提交创建补丁。所以你必须先执行git commit

此外 - 我不认为 --stdout 会如您所想。

从这里开始:https://git-scm.com/docs/git-format-patch

The names of the output files are printed to standard output, unless the --stdout option is specified.

format-patch 为您的每个提交创建一个补丁文件。它不输出文件本身,而是输出补丁文件的名称。

您必须有一些内容(提交)才能创建路径。
提交您的更改并创建补丁

git format-patch HEAD~X // x is the number of commits you need