如何显示部分或全部文件之间的差异? GIT [英] how to show differences between some or all files? GIT

查看:85
本文介绍了如何显示部分或全部文件之间的差异? GIT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像主题中一样:如何显示某些或所有文件之间的差异?

As in the subject: how to show differences betwen some or all files?

对不起,我已经弄清楚了我的问题.我的意思是在一个或多个或所有文件的分支之间存在差异.

Sorry i've screwed up my question. I meant differences betwen branches for one or multiple or all files.

推荐答案

也许更有用:

git diff <commit1> <commit2> -- path/to/file.cpp path/to/anotherfile.cpp path/to/subdir

您还可以(例如bash)

You can also (in e.g. bash)

git diff {<commit1>,<commit2>}:path/to/file.cpp

这样您甚至可以

git diff <commit1>:path/to/file.cpp <commit2>:path/to/anotherfile.cpp

功能强大,恕我直言.

which is quite insane powerful, IMHO.

用标记,分支(本地或远程)的任何名称或提交的直接sha1哈希(称为 commit-ish )替换<commit1><commit2>

Replace <commit1> and <commit2> by any name of tag, branch (local or remote) or direct sha1 hash of a commit (this is known as a commit-ish)

要变得非常时髦,可以根据需要指定树状哈希或blob哈希值.为此,做一些完全愚蠢的事情:

To get really funky, you can specify tree-ish or blob hashes if you want. Do something completely silly with this for a sample:

$ git ls-tree HEAD^ | grep blob | sort -R | head -2
100644 blob 27785581e788049ac805fab1d75744dd7379735d    .gitignore
100644 blob 2821a5271ffd8e6b11bb26b8571f57e88ab81f38    TESTING

$ git diff --stat 2821a5271ffd8e6b11bb26b8571f57e88ab81f38 aa96765714a3058068c4425d801fab4b64e26066
 ...f38 => aa96765714a3058068c4425d801fab4b64e26066 |  155 +++++++++++++++++---
 1 files changed, 135 insertions(+), 20 deletions(-)

现在,通常不会执行此操作,除非您的回购中有多个相同"文件版本(如果询问我的话,这是很困难的话).

Now you won't usually do this, unless you have several versions of the 'same' file in you repo (which is iffy, if you ask me).

这篇关于如何显示部分或全部文件之间的差异? GIT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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