If you're using Git from the command line, is there a way to delete in one fell swoop all the files to be deleted in the Changed but not updated list? Rather than doing manual removes using wildcards.
Well, the files listed under Changed but not updated are already in the index. You can discard their changes by using git checkout .
To remove file that are new, but have not been added to the index you can use git clean
.
But for deleting files that are modified and in the index ... well there is no easy solution, you probably have to use a combination of git rm
and git ls-files
.
EDIT:
git ls-files -m
should list the files you are looking for. Combine it with git rm
and you are done:
git-ls files -m | xargs git rm // NOT TESTED
EDIT:
I probably misunderstood a part of your question. My solution will delete all files listed under Changed but not updated. If you want to remove the files listed as deleted, you have to use git diff
as Charles Bailey shows in his answer.
Files shown as deleted in the "Changed but not updated" section of status are deleted from the work tree but not from the index. To stage the deletion in the index (i.e. remove the file from the index) you can do:
git diff -z --name-only --diff-filter=D | git update-index --remove -z --stdin
--diff-filter=D
shows only the differences to the index that are deleted files, --name-only
just prints their name and -z
uses NUL to separate file names so that you don't have to worry about filenames with embedded newlines. update-index
then removes the given files from the index.
If you have a version of xargs
that supports -0
then you could do the slightly simpler:
git diff -z --name-only --diff-filter=D | xargs -0 git rm