# git: Fix stage/unstage failure with a large number of files \(\#47800\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/839b4f1e60acd6f67e9b50f6bad5bc3284835872)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 839b4f1e60acd6f67e9b50f6bad5bc3284835872

Requested commit: 839b4f1e60acd6f67e9b50f6bad5bc3284835872

Commit: 839b4f1e60acd6f67e9b50f6bad5bc3284835872

Tree: d09b985558b493de9838bda856ad3ad8710dc329

Author: Marco Mihai Condrache

Committer: GitHub

## Message

```
git: Fix stage/unstage failure with a large number of files (#47800)

Git commands can fail when staging or unstaging a very large number of
files because each file path is passed as a separate CLI argument. Once
the argument list grows beyond the OS limit, git errors with Argument
list too long (os error 7).

Since git 2.26, pathspecs can be read from stdin, which lets us avoid
passing thousands of paths as arguments and bypass this limitation.

I looked for existing issues related to this but couldn’t find any.

Repro:

- Clone rust-lang repo
- Delete root tests folder
- Try to stage or unstage (40,000+ files)
- Git fails with Argument list too long (os error 7)

Release Notes:

- Fixed an issue where stage/unstage could fail when operating on a very
large number of files
```

## Parents

- [c2959a7f7e37ba5b2aa83ba0cacde14fe9fd3b49](https://git.cafe/gitcafe/zed/commit/c2959a7f7e37ba5b2aa83ba0cacde14fe9fd3b49?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/839b4f1e60acd6f67e9b50f6bad5bc3284835872?format=markdown)
