Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在做一个使用 git 的项目。每当我进行更改时,我都会向应用并提交它的主要开发人员提交一个补丁。到目前为止,事情进展顺利:
git diff > somepatch.patch
但是当我创建新文件时,上面的命令不起作用。它会创建一个不包含我创建的新文件的补丁。我尝试像这样将它们添加到git:-
git add path/to/the/file.qml
但这也行不通。
如果您已经将更改添加到 repo,它们将不会出现在git diff输出中,除非您使用--staged参数请求已添加到 index.html 的更改。
git diff
--staged
git diff --staged > your.patch
因此,如果您混合了已添加和未添加的更改,您甚至可以使用
git add .
然后继续你的差异。
作为旁注,另一种方法是取消所有内容并在没有以下情况下进行经典差异--staged:
git reset HEAD git diff > your.patch