[英]Compare 2 files on 2 different branches on GIT
我必须比较GIT的2个不同分支上的2个文件。之后,我需要将其合并到master。
我看见了这个 :
git diff branch1:full/path/to/foo.txt branch2:full/path/to/foo-another.txt
您能告诉我如何填充完整路径以及branch1和branch2吗?
更新:我曾这样尝试过,但是没用。你能告诉我为什么吗?
git diff
master:https://github.com/MyGit/blob/master/My.Web/App/tenant/views/propertymana
gement/index.less access-ui:https://github.com/MyGit/blob/access-
ui/My.Web/App/tenant/views/propertymanagement/index.less
上面的命令给出了这个错误 :
fatal: Path 'https://github.com/MyGit/blob/master/My.Web/App/t
enant/views/propertymanagement/index.less' does not exist in 'master'
您能告诉我如何填充完整路径以及branch1和branch2吗?
它是工作树中当前路径的相对路径,而不是文件的URI。
对于具有两个文件夹dir1和dir2的本地工作树,您现在位于dir1中,并且想要比较dir1中的文件,请使用以下命令:
git diff branch1:file1.c branch2:file1
要比较dir2中的文件,请使用以下命令。
git diff branch1:../dir2/file2.c branch2:../dir2/file2.c
您也可以比较不同文件夹中具有不同文件名的文件,即,以下命令可以。
git diff branch1:file1.c branch2:../dir2/file2.c
git diff yourbranch1 yourbranch2 -- yourfile.txt
或使用Meld或任何git diff工具。
您不需要完整路径,但是需要相对于相关树的路径。
从git-diff文档中:
git diff [--options] <commit> <commit> [--] [<path>…]
This is to view the changes between two arbitrary <commit>.
采用:
git diff master access-ui My.Web/App/tenant/views/propertymanagement/index.less
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.