diff: add --include-untracked to show new files - #2424
Draft
HaraldNordgren wants to merge 1 commit into
Draft
HaraldNordgren wants to merge 1 commit into
HaraldNordgren wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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".