how show the diff from my current working directory and my last commit?

▼魔方 西西 提交于 2019-12-23 12:07:43

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/14035068/how-show-the-diff-from-my-current-working-directory-and-my-last-commit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!