Search code examples
gitgit-stash

How to remove "<file_path>/file.py~Stashed changes" from git status


After doing some git stashing and branch changes, I somehow have the following in my git status:

Untracked files:  (use "git add <file>..." to include in what will be committed)

    "<file_path>/file.py~Stashed changes"

But when I try to do git rm <file> or git add <file>, I'm getting:

fatal: pathspec '<file_path>/file.py~Stashed' did not match any files

How do I remove this file path from my git status?


Solution

  • You should use just rm "<file_path>/file.py~Stashed changes"

    As per the manual:

    git rm Remove files from the index, or from the working tree and the index. git rm will not remove a file from just your working directory.

    Since your file is untracked, git rm won't remove it.

    If you have many files to deal with, have a look at git clean.