如何在网络上的 2 个文件夹中的所有文件之间获取差异?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5874090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get diff between all files inside 2 folders that are on the web?
提问by Rella
So I want to compare this folderhttp://cloudobserver.googlecode.com/svn/branches/v0.4/Boost.Extension.Tutorial/libs/boost/extension/
with thishttp://svn.boost.org/svn/boost/sandbox/boost/extension/
. I want to get a diff file as a result. These folders are under svn control but I'd prefer git styled diff file (like one shown here) I tried git diff
but it seems not to work that way for web folders. So how to do the same thing with one command on Linux?
所以我想把这个文件夹http://cloudobserver.googlecode.com/svn/branches/v0.4/Boost.Extension.Tutorial/libs/boost/extension/
和这个http://svn.boost.org/svn/boost/sandbox/boost/extension/
. 结果我想得到一个差异文件。这些文件夹受 svn 控制,但我更喜欢 git 样式的 diff 文件(如此处所示),我尝试过,git diff
但似乎不适用于 Web 文件夹。那么如何在 Linux 上用一个命令做同样的事情呢?
Update:So we had a great answer. But it works strangely - it seems to me it shows that all files (same files) have all theire contents replaced with very same contents (while I know for sure that there were only like 3-4 code lines changed at all)...
更新:所以我们有一个很好的答案。但它的工作方式很奇怪 - 在我看来,它表明所有文件(相同文件)的所有内容都替换为非常相同的内容(虽然我确信只有 3-4 行代码发生了变化)......
Update 2:To achieve what I really needed (dif file with only really changed lines, with git styling, on Linux) do:
更新 2:要实现我真正需要的(dif 文件,只有真正改变的行,带有 git 样式,在 Linux 上),请执行以下操作:
$ svn export http://cloudobserver.googlecode.com/svn/branches/v0.4/Boost.Extension.Tutorial/libs/boost/extension/ repos2 --native-eol CRLF
$ svn export http://svn.boost.org/svn/boost/sandbox/boost/extension/ repos --native-eol CRLF
$ git diff repos repos2 > fileWithReadableDiff.diff
采纳答案by sehe
Once you have the source trees, e.g.
一旦你有了源树,例如
diff -ENwbur repos1/ repos2/
Even better
甚至更好
diff -ENwbur repos1/ repos2/ | kompare -o -
and have a crack at it in a good gui tool :)
并在一个好的 gui 工具中破解它:)
- -Ewb ignore the bulk of whitespace changes
- -N detect new files
- -u unified
- -r recurse
- -Ewb 忽略大量空白更改
- -N 检测新文件
- -u 统一
- -r 递归
回答by yvoyer
You urls are not in the same repository, so you can't do it with the svn diff
command.
您的网址不在同一个存储库中,因此您无法使用该svn diff
命令执行此操作。
svn: 'http://svn.boost.org/svn/boost/sandbox/boost/extension' isn't in the same repository as 'http://cloudobserver.googlecode.com/svn'
Another way you could do it, is export each repos using svn export
, and then use the diff command to compare the 2 directories you exported.
另一种方法是使用 导出每个存储库svn export
,然后使用 diff 命令比较导出的 2 个目录。
// Export repositories
svn export http://svn.boost.org/svn/boost/sandbox/boost/extension/ repos1
svn export http://cloudobserver.googlecode.com/svn/branches/v0.4/Boost.Extension.Tutorial/libs/boost/extension/ repos2
// Compare exported directories
diff repos1 repos2 > file.diff