How do I easily remove several files without manually typing the full paths of all of them to git rm
? I have plenty of modified files I'd like to keep so removing all modified is not possible either.
And also it is possible to revert the changes of several files without manually typing git checkout -- /path/to/file
?
You can give wildcards to
git rm
.e.g.
Or you can just write down the names of all the files in another file, say
filesToRemove.txt
:You can automate this:
Open the file and review the names (to make sure it's alright).
Then:
Or:
Check the manpage for
xargs
for more options (esp. if it's too many files).You can simply use:
For removing multiple files at once, you might want to checkout the answer here
You can delete the files that you don't want and run this command:
git rm $(git ls-files --deleted)
Just delete them using any other method (Explorer, whatever), then run
git add -A
. As to reverting several files, you can also checkout a directory.You simply use
to remove many files match the wildcards.
You could also check out Cygwin, as it provides much of the Unix/Linux/*BSD functionality on Windows. Cygwin includes a Bash shell and find(1), among other tools mentioned above. (I usually have 2-4 Cygwin mintty terminals up at one time on Windows 7 because I find Cygwin that handy.)