Maxim Yefremov
Maxim Yefremov

Reputation: 14185

remove deleted files from git: Argument list too long

I try to remove deleted files from git:

git rm `git status | grep deleted | awk '{print $3}'`

But got error in mac bash:

-bash: /usr/local/git/bin/git: Argument list too long

If I run ...

git status | grep deleted | awk '{print $3}'

... I successfully got list of files to be deleted. But how to delete them from git?

Upvotes: 1

Views: 3477

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799150

xargs will limit the command length to something the shell won't choke on and invoke the command passed as many times as required.

git status | grep deleted | awk '{print $3}' | xargs git rm

Upvotes: 7

Related Questions