如何显示我当前工作目录和最近一次提交的差异? [英] how show the diff from my current working directory and my last commit?

查看:149
本文介绍了如何显示我当前工作目录和最近一次提交的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用git,并将需要包含在diff结果未追踪的文件中。那么,我必须执行什么命令才能获得当前工作目录和HEAD之间的所有区别,甚至在新文件中还存在一部分差异?

解决方案

嗯, git diff ?毕竟,它就是这样。



更新:不在展示区域的文件并不意味着未跟踪的文件。这是两个不同的类别。当 git add 它时,文件或更改将变为暂存。未跟踪的文件是目前没有被git跟踪的文件,而这些文件似乎是您根据您的评论询问的。我没有办法知道让git显示未跟踪文件的差异。鉴于他们没有跟踪,它没有任何意义。你所要求的只是查看一些文件的内容。 Git能够使用 ls-files 列出未跟踪的文件,因此如果您使用的是* nix格式,您可以轻松构建一条命令来执行您要查找的内容-like环境:

  git ls-files -o | xargs cat 

-o 选项告诉它列出所有未跟踪文件的名称。上面自然只是将所有未跟踪文件的内容打印到标准输出。


I'm using git and need included in the diff result untracked files. So what command I must execute to get all the difference between my current working directory and the HEAD, even part of the difference exist in the new file addition?

解决方案

Um, git diff? That's what it does, after all.

Update: "Files that aren't in the staged area" doesn't mean "untracked files". Those are two, separate categories. A file or change becomes "staged" when you git add it. Untracked files are ones that aren't presently being tracked by git, and these seem to be the ones you're asking about based on your comment. There's no way that I know of to have git show you a diff of untracked files. It doesn't really make sense, given that they're untracked. All you're asking for is to see the content of some files. Git does have the ability to list untracked files with ls-files, so you could easily construct a command to do what you're looking for if you're in a *nix-like environment:

git ls-files -o | xargs cat

The -o option tells it to list the names of all untracked files. The above would naturally just print out the content of all untracked files to stdout.

这篇关于如何显示我当前工作目录和最近一次提交的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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