How to use Git rm to deal with “Argument list too long” error

You may receive an “Argument list too long” error message when trying to do a Git rm. This occurs when the list of arguments exceeds the system limit.

The solution to this problem is to use the following command: git ls-files --full-name -i --exclude-from=.gitignore | xargs git rm --cached

This command first searches for files that match the pattern specified in the .gitignore file. Then it passes those files to the git rm command to remove them from the cache.

Reference: https://qiita.com/SShayashi/items/1fef1bb11439891a5e2c

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top