Bird
0
0

You ran git stash push but accidentally included untracked files. Which command fixes this by stashing only tracked files?

medium📝 Troubleshoot Q14 of 15
Git - Stashing
You ran git stash push but accidentally included untracked files. Which command fixes this by stashing only tracked files?
Agit stash push --keep-index
Bgit stash push --only-tracked
Cgit stash push --no-untracked
Dgit stash push --include-untracked
Step-by-Step Solution
Solution:
  1. Step 1: Understand the problem with untracked files

    By default, git stash push does not stash untracked files unless specified.
  2. Step 2: Identify the correct option to stash only tracked files

    --keep-index stashes changes but keeps the index intact, effectively ignoring untracked files.
  3. Final Answer:

    git stash push --keep-index -> Option A
  4. Quick Check:

    Use --keep-index to stash only tracked files [OK]
Quick Trick: Use --keep-index to exclude untracked files from stash [OK]
Common Mistakes:
  • Using --include-untracked adds untracked files instead of excluding
  • Assuming --no-untracked or --only-tracked are valid options
  • Confusing stash options with git add options

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes