如何在同一分支上的两个不同提交之间区分同一个文件? [英] How do I diff the same file between two different commits on the same branch?

查看:94
本文介绍了如何在同一分支上的两个不同提交之间区分同一个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Git中,我怎么能比较同一个分支上两个不同的提交(不是连续的)之间的同一个文件?(例如master)?

我正在搜索对于 Visual SourceSafe / a>(VSS)或 Team Foundation Server (TFS)。是否有可能在Git?

解决方案

git-diff manpage:

  git diff [--options]< commit> <提交> [ - ] [< path> ...] 

例如,现在和两个提交之间的文件main.c提交,这里有三个等价的命令:

  $ git diff HEAD ^^ HEAD main.c 
$ git diff HEAD ^^ .. HEAD - main.c
$ git diff HEAD〜2 HEAD - main.c


In Git, how could I compare the same file between two different commits (not contiguous) on the same branch (master for example)?

I'm searching for a compare feature like the one in Visual SourceSafe (VSS) or Team Foundation Server (TFS). Is it possible in Git?

解决方案

From the git-diff manpage:

git diff [--options] <commit> <commit> [--] [<path>...]

For instance, to see the difference for a file "main.c" between now and two commits back, here are three equivalent commands:

$ git diff HEAD^^ HEAD main.c
$ git diff HEAD^^..HEAD -- main.c
$ git diff HEAD~2 HEAD -- main.c

这篇关于如何在同一分支上的两个不同提交之间区分同一个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆