使用difftool,同一文件的暂存版本和未暂存版本之间的差异 [英] Differences between the staged and unstaged versions of the same file, using difftool

查看:155
本文介绍了使用difftool,同一文件的暂存版本和未暂存版本之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以查看同一文件的stagedunstaged版本之间的差异?

Is there a way of viewing the differences between the staged and unstaged versions of the same file?

例如:

Changes to be committed:

    modified:   conf/application.conf

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   conf/application.conf

发生这种情况的原因是:我先进行更改,然后再次修改文件而不进行登台.

This happens when I stage a change and then I modify the file again, without staging it.

EDIT

git status -vv命令不够好,因为我需要使用diff/difftool命令.这是因为在实践中,太多文件中的更改太多,因此滚动浏览所有文件效率不高.但是diff/difftool允许我指定我感兴趣的文件.

The git status -vv command is not good enough, because I need to use the diff / difftool command. That's because in practice there are too many changes in too many files, and scrolling through all of them is not efficient. But diff / difftool allows me to specify the file I am interested in.

推荐答案

git diff将显示您的工作空间与索引之间的差异. (索引是暂存文件所在的位置)

git diff will show the difference between your workspace and the index. (the index is where the staged files live)

这似乎不太明显,因为我们通常使用git diff来查看工作空间与已签入内容之间的更改.但是,从技术上讲,git diff显示工作空间与索引之间的关系,并且如果您尚未对索引进行更改, ,则索引与您签出的内容匹配.

This may not seem obvious because we usually use git diff to see the changes in the workspace vs what is checked in. However, technically git diff shows workspace vs index, and if you haven't added changes to the index, then the index matches what you checked out.

  • 查看工作区与仓库:git diff HEAD
  • 查看索引与存储库:git diff --cached(也可以使用--staged)
  • 查看工作空间与索引:git diff
  • to see workspace vs repo: git diff HEAD
  • to see index vs repos: git diff --cached (can also use --staged)
  • to see workspace vs index: git diff

这篇关于使用difftool,同一文件的暂存版本和未暂存版本之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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