diff命令'diff -b'和'git diff'之间的区别 [英] Difference between the diff command 'diff -b' and 'git diff'
问题描述
在处理 git repo
时,我总是使用 diff -b
来创建补丁。
- 这两者之间的区别是什么,也是内部的
git diff / git format-patch 使用linux / unix diff
命令? (我知道git diff / git format-patch
之间的区别) - 另外,如何修补
patch -p1
不同于git apply
。我可以应用由diff
命令(diff -b
)生成的补丁并使用git diff
? - 处理<$时使用
git diff / apply
C $ C> GIT中?我一直在使用diff / patch
,并且从来没有遇到过任何问题。
请纠正我,如果我的知识上面提到的东西是不够的。
b $ b
-
Git有其自己的内置差异,但两者的输出非常相似,只要有正确的选项。使用内置的diff和
git diff
前端可以获得很多自动化,并且输出始终是git apply code>或
git am
会喜欢。简而言之,它只是更方便 。 我已经完成了这样的事情(fed
git diff
输出到补丁
,或者普通 diff
输出到 git apply
)。它的工作原理,虽然偶尔我不得不编辑的东西在这里和那里得到它的工作,这是一个痛苦。如果我想要 git apply
,或者只是获得 git diff
或者 git am
一个补丁。一般情况下最大的可观察的区别在于, git apply
默认不会部分应用:您必须添加 - reject
使其表现得像补丁的默认。 (另外,所有这些 .orig
文件...) 是的,因为方便。当你进一步了解并使用 git format-patch
和 git am
时,可以批量应用整个系列维护提交信息,包括作者信息等,并自动提交所有内容。
I have always used diff -b
to make patches even when working on a git repo
.
- What is the difference between the two, does
git diff / git format-patch
also internally makes use of the linux/unixdiff
command? (I know the difference betweengit diff/git format-patch
) - Also, how is patching with
patch -p1
different fromgit apply
. Can i apply a patch generated by thediff
command (diff -b
) and apply usinggit diff
? - Is it a good practice to use
git diff/apply
when working withgit
? I have been usingdiff/patch
and never faced any problem.
Please correct me if my knowledge of things mentioned above is not adequate.
In order:
Git has its own built-in diff but the outputs of both are quite similar, given the right options. Using the built-in diff and the
git diff
front-end gets you a whole lot of automation, plus the output is always somethinggit apply
orgit am
will like. In short, it's just a lot more convenient.I've done this sort of thing (fed
git diff
output topatch
, or plaindiff
output togit apply
). It works, although occasionally I have had to edit things here and there to get it to work, which is a pain. It's much more convenient to just get agit diff
if I want togit apply
orgit am
a patch. The biggest observable difference in general is thatgit apply
does not do partial apply by default: you must add--reject
to make it act like patch's default. (Also, all those.orig
files...)Yes, because of said convenience. When you go a bit further and use
git format-patch
andgit am
, you can mass-apply a whole series of patches, maintaining commit messages including authorship information and so on, and getting everything committed automatically.
这篇关于diff命令'diff -b'和'git diff'之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!