I'm having problems feeding a large list of filenames into a command in (git for windows git, I think it's cygwin)bash shell.
This is the basic command that works fine with a small set of arguments: git filter-branch -f --tree-filter 'rm -rf file1 directory2 file3 file4'
However, I have about 1500 filenames.
I've tried: git filter-branch -f --tree-filter 'rm -rf file1 directory2... all 1500 names here'
but I get an error:
/mingw64/bin/git: Argument list too long
I've tried to use a for loop: git filter-branch -f --tree-filter 'for f in $(cat files.txt) ; do rm -fr "$f" ; done'
and this runs through the loop with an error:
cat: files.txt: No such file or directory
FYI - the files.txt contents look like this:
./file1
./directory2
./file3
./file4
Then I tried: git filter-branch -f --tree-filter < cat files.txt
and cat files.txt | git filter-branch -f --tree-filter
but I get errors about the syntax not being correct - it shows the 'help' dialogue. eg:
usage: git filter-branch [--setup ] [--subdirectory-filter ] [--env-filter ] [--tree-filter ] [--index-filter ] [--parent-filter ] [--msg-filter ] [--commit-filter ] [--tag-name-filter ] [--original ] [-d ] [-f | --force] [--state-branch ] [--] [...]
Then I thought maybe I could just add the arguments into the file like this: git filter-branch -f
File:
--tree-filter './file1 ./directory2 ./file3 ./file4'
But I get the 'help' dialogue again.
I'm sure there is a way to do this, but my unix-fu is too weak. Please help!
In response to @dash-o:
I tried this, but am getting an error:
C:/Program Files/Git/mingw64/libexec/git-core\git-filter-branch: eval: line 414: unexpected EOF while looking for matching `'' C:/Program Files/Git/mingw64/libexec/git-core\git-filter-branch: eval: line 415: syntax error: unexpected end of file
The files.txt lists the files one per line. However, the rm -rf requires them to be on a single line and space-delimited.
I tried to put the files names on a single line, but I get a different error:
C:/Program Files/Git/mingw64/libexec/git-core\git-filter-branch: line 414: rm -rf .vs ./file1 ./directory2: command not found tree filter failed: 'rm -rf ./file1 ./directory2'
Maybe the single quotes are being escaped and are not wrapped around the rm command?