问题描述
我试图通过创建一个补丁文件。
It将是最初的补丁。
I am trying to create a patch file to be used via reviewboard.
It will be the initial patch.
diff -ruN --exclude = .git empty_dir working_dir> mypatch_00.patch
的作品,但我得到一个选定的文件似乎不是差异。错误。
diff -ruN --exclude=.git empty_dir working_dir > mypatch_00.patch
works but I am getting a "The selected file does not appear to be a diff." error.
有什么办法让它使用git-diff或diff?谢谢
Is there any way to get it working using git-diff or diff? Thank you
推荐答案
如果您想为最初的提交获取差异(也许我误解了您的问题),您可以使用
If you want to get diff for your initial commit (maybe I misunderstood your question), you can display it using
git show COMMIT
或者将其作为文件:
Alternatively to get it as file:
git format-patch -1 COMMIT
其中 COMMIT
是此提交的修订。如果这也是您当前的提交,那么您不必指定它。
Where COMMIT
is revision of this commit. If this is your current commit as well, you don't have to specify it at all.
但是,如果您的提交不是初始化,并且想要获得完全差异你的历史,你需要首先创建空分支:
However if your commit is not initial and you want to get full diff for your history, you need to create empty branch first:
git checkout --orphan empty # Create orphaned branch
git read-tree --empty # Remove all files from index
git commit --allow-empty -m 'Empty' # Initial commit
现在你可以对空分支做全差异:
Now you can do full diff against empty branch:
git diff empty..master
这篇关于从无到有创建一个git diff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!