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

1

6

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?

Qatar answered 26/12, 2012 at 1:1 Comment(1)
NOTE: git diff shows nothing if all you did was make new files -- (mentioned in the answer comments)Gahnite
H
9

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.

Handed answered 26/12, 2012 at 1:18 Comment(2)
Nothing show up when the only things I did in my working directory was add new files. In the question body a put 'need included files that aren't in the staged area'. Thanks anyway.Qatar
You are right about staged and untracked files, I said staged while referring to untracked files. I will update my question. But what I'm asking have sense, just think about... I want see that will be added to my staged after a git add . before execute the command, and for that I need a kind of combination of git diff plus git ls-files -o | xargs cat, is think that git must have a command to get what I want, git interact with the working directory in many ways, I think this could be a good one, I not share with you "It doesn't really make sense, given that they're untracked" idea.Qatar

© 2022 - 2024 — McMap. All rights reserved.