Skip to content

diff: add --include-untracked to show new files - #2424

Draft
HaraldNordgren wants to merge 1 commit into
git:masterfrom
HaraldNordgren:diff-include-untracked
Draft

HaraldNordgren wants to merge 1 commit into
git:masterfrom
HaraldNordgren:diff-include-untracked

Conversation

@HaraldNordgren

Copy link
Copy Markdown
Contributor

Before committing, it is common to want one diff of everything that is not yet committed. "git diff HEAD" covers staged and unstaged changes but leaves out files that were never added. Today the only way to get them into a diff is "git add -N", which changes the index and makes "git commit -a" pick those files up afterwards.

This teaches "git diff" an --include-untracked option that shows untracked files as new files, the same way "git add -N" would, without touching the index. Ignored files stay hidden, pathspecs apply, and the option is rejected together with --cached. The name follows "git stash show --include-untracked".

Before committing, users often want to review everything they are
about to lose or record, but "git diff HEAD" says nothing about files
that were never added. The only way to see them in a diff today is
"git add -N", which changes the index and makes "git commit -a" pick
those files up afterwards.

Teach "git diff" an --include-untracked option that shows untracked
files as new files, the same way they would appear after "git add -N",
while leaving the index alone. Ignored files are not shown, and
pathspecs limit which untracked files are included. The option name
matches the one "git stash show" already uses for the same purpose.

The option is only meaningful when the working tree is one side of
the comparison, so it is rejected together with --cached.

Signed-off-by: Harald Nordgren <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant