Issue
how are you doing? Let me explain what is happening to me:
I've created a UE5 project and there are some huge files, I'm trying to remove them from the git directory
using the command git rm --cached
. When I try to delete a single file, using git rm --cached example/path/path
, it works very well, like the image-0 shows:
image-0
But when I put all paths in a single file, and try to use a while loop to delete them one by one, it doesn't work! I tried to use the command:
while read line; do git rm --cached "$line"; done < filestoremove.txt
and I got the error:
error fatal: pathspec 'example/path/file.example?' did not match any files
Like the image-1 shows:
image-1
I've checked if the file had any special characters using Notepad++ and certified that the file is UTF-8. How u can see, the filestoremove.txt is in the same directory that Content/ folder is, take a look at image-2: image-2
An example of content in the file, image-3: image-3
As you can imagine it isn't possible to remove each one using git rm to each file without a loop command.
I want to delete all archives listed in the filestoremove.txt using a single command.
Solution
Thank you guys, specially to user jhnc, his solution works for me, just do it:
dos2unix file.txt
Then run the loop in git bash:
while read line; do git rm --cached "$line"; done < files.txt
Answered By - Rai Bizerra Maciel Answer Checked By - David Marino (WPSolving Volunteer)