diff --git a/pre_commit/commands/try_repo.py b/pre_commit/commands/try_repo.py
index c9849ea..3e256ad 100644
--- a/pre_commit/commands/try_repo.py
+++ b/pre_commit/commands/try_repo.py
@@ -15,6 +15,7 @@ from pre_commit.commands.run import run
 from pre_commit.store import Store
 from pre_commit.util import cmd_output
 from pre_commit.util import tmpdir
+from pre_commit.xargs import xargs
 
 logger = logging.getLogger(__name__)
 
@@ -32,9 +33,15 @@ def _repo_ref(tmpdir, repo, ref):
         shadow = os.path.join(tmpdir, 'shadow-repo')
         cmd_output('git', 'clone', repo, shadow)
         cmd_output('git', 'checkout', ref, '-b', '_pc_tmp', cwd=shadow)
+
         idx = git.git_path('index', repo=shadow)
         objs = git.git_path('objects', repo=shadow)
         env = dict(os.environ, GIT_INDEX_FILE=idx, GIT_OBJECT_DIRECTORY=objs)
+
+        staged_files = git.get_staged_files(cwd=repo)
+        if staged_files:
+            xargs(('git', 'add', '--'), staged_files, cwd=repo, env=env)
+
         cmd_output('git', 'add', '-u', cwd=repo, env=env)
         git.commit(repo=shadow)
 
diff --git a/pre_commit/git.py b/pre_commit/git.py
index c24ca86..3b97bfd 100644
--- a/pre_commit/git.py
+++ b/pre_commit/git.py
@@ -91,11 +91,12 @@ def get_conflicted_files():
     return set(merge_conflict_filenames) | set(merge_diff_filenames)
 
 
-def get_staged_files():
+def get_staged_files(cwd=None):
     return zsplit(cmd_output(
         'git', 'diff', '--staged', '--name-only', '--no-ext-diff', '-z',
         # Everything except for D
         '--diff-filter=ACMRTUXB',
+        cwd=cwd,
     )[1])
 
 
diff --git a/pre_commit/xargs.py b/pre_commit/xargs.py
index a382759..f32cb32 100644
--- a/pre_commit/xargs.py
+++ b/pre_commit/xargs.py
@@ -109,6 +109,7 @@ def xargs(cmd, varargs, **kwargs):
     """
     negate = kwargs.pop('negate', False)
     target_concurrency = kwargs.pop('target_concurrency', 1)
+    max_length = kwargs.pop('_max_length', _get_platform_max_length())
     retcode = 0
     stdout = b''
     stderr = b''
@@ -118,10 +119,10 @@ def xargs(cmd, varargs, **kwargs):
     except parse_shebang.ExecutableNotFoundError as e:
         return e.to_output()
 
-    partitions = partition(cmd, varargs, target_concurrency, **kwargs)
+    partitions = partition(cmd, varargs, target_concurrency, max_length)
 
     def run_cmd_partition(run_cmd):
-        return cmd_output(*run_cmd, encoding=None, retcode=None)
+        return cmd_output(*run_cmd, encoding=None, retcode=None, **kwargs)
 
     threads = min(len(partitions), target_concurrency)
     with _thread_mapper(threads) as thread_map:

try-repo with unstaged commits sometimes doesn't work
```
$ git status
On branch pre_commit
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	new file:   .pre-commit-hooks.yaml

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	build/
	dist/
```

```
$ pre-commit try-repo ../setup-cfg-fmt/
[WARNING] Creating temporary repo with uncommitted changes...
An unexpected error has occurred: CalledProcessError: Command: ('/usr/bin/git', 'commit', '--no-edit', '--no-gpg-sign', '-n', '-minit')
Return code: 1
Expected return code: 0
Output: 
    On branch _pc_tmp
    nothing to commit, working tree clean
    
Errors: (none)

Check the log at /home/asottile/.cache/pre-commit/pre-commit.log
```

```
$ cat /home/asottile/.cache/pre-commit/pre-commit.log
An unexpected error has occurred: CalledProcessError: Command: ('/usr/bin/git', 'commit', '--no-edit', '--no-gpg-sign', '-n', '-minit')
Return code: 1
Expected return code: 0
Output: 
    On branch _pc_tmp
    nothing to commit, working tree clean
    
Errors: (none)

Traceback (most recent call last):
  File "/home/asottile/opt/venv/lib/python3.6/site-packages/pre_commit/error_handler.py", line 46, in error_handler
    yield
  File "/home/asottile/opt/venv/lib/python3.6/site-packages/pre_commit/main.py", line 295, in main
    return try_repo(args)
  File "/home/asottile/opt/venv/lib/python3.6/site-packages/pre_commit/commands/try_repo.py", line 48, in try_repo
    repo, ref = _repo_ref(tempdir, args.repo, args.ref)
  File "/home/asottile/opt/venv/lib/python3.6/site-packages/pre_commit/commands/try_repo.py", line 39, in _repo_ref
    git.commit(repo=shadow)
  File "/home/asottile/opt/venv/lib/python3.6/site-packages/pre_commit/git.py", line 143, in commit
    cmd_output(*cmd, cwd=repo, env=env)
  File "/home/asottile/opt/venv/lib/python3.6/site-packages/pre_commit/util.py", line 153, in cmd_output
    returncode, cmd, retcode, output=(stdout, stderr),
pre_commit.util.CalledProcessError: Command: ('/usr/bin/git', 'commit', '--no-edit', '--no-gpg-sign', '-n', '-minit')
Return code: 1
Expected return code: 0
Output: 
    On branch _pc_tmp
    nothing to commit, working tree clean
    
Errors: (none)
```
diff --git a/tests/commands/try_repo_test.py b/tests/commands/try_repo_test.py
index 5b50f42..d9a0401 100644
--- a/tests/commands/try_repo_test.py
+++ b/tests/commands/try_repo_test.py
@@ -123,3 +123,15 @@ def test_try_repo_uncommitted_changes(cap_out, tempdir_factory):
         config,
     )
     assert rest == 'modified name!...........................................................Passed\n'  # noqa: E501
+
+
+def test_try_repo_staged_changes(tempdir_factory):
+    repo = make_repo(tempdir_factory, 'modified_file_returns_zero_repo')
+
+    with cwd(repo):
+        open('staged-file', 'a').close()
+        open('second-staged-file', 'a').close()
+        cmd_output('git', 'add', '.')
+
+    with cwd(git_dir(tempdir_factory)):
+        assert not try_repo(try_repo_opts(repo, hook='bash_hook'))
diff --git a/tests/xargs_test.py b/tests/xargs_test.py
index a6cffd7..71f5454 100644
--- a/tests/xargs_test.py
+++ b/tests/xargs_test.py
@@ -208,3 +208,13 @@ def test_thread_mapper_concurrency_uses_threadpoolexecutor_map():
 def test_thread_mapper_concurrency_uses_regular_map():
     with xargs._thread_mapper(1) as thread_map:
         assert thread_map is map
+
+
+def test_xargs_propagate_kwargs_to_cmd():
+    env = {'PRE_COMMIT_TEST_VAR': 'Pre commit is awesome'}
+    cmd = ('bash', '-c', 'echo $PRE_COMMIT_TEST_VAR', '--')
+    cmd = parse_shebang.normalize_cmd(cmd)
+
+    ret, stdout, _ = xargs.xargs(cmd, ('1',), env=env)
+    assert ret == 0
+    assert b'Pre commit is awesome' in stdout

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio mock
apt-get update apt-get install -y gcc
3.9
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
aspy.yaml==1.3.0
cfgv==3.4.0
coverage==7.8.0
distlib==0.3.9
exceptiongroup==1.2.2
execnet==2.1.1
filelock==3.18.0
identify==2.6.9
importlib_metadata==8.6.1
iniconfig==2.1.0
mock==5.2.0
nodeenv==1.9.1
packaging==24.2
platformdirs==4.3.7
pluggy==1.5.0
-e git+https://github.com/pre-commit/pre-commit.git@71c238d4ec61c0568949087f969bf9488663d578#egg=pre_commit
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
PyYAML==6.0.2
six==1.17.0
toml==0.10.2
tomli==2.2.1
typing_extensions==4.13.0
virtualenv==20.29.3
zipp==3.21.0

name: pre-commit
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - aspy-yaml==1.3.0
      - cfgv==3.4.0
      - coverage==7.8.0
      - distlib==0.3.9
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - filelock==3.18.0
      - identify==2.6.9
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - mock==5.2.0
      - nodeenv==1.9.1
      - packaging==24.2
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - pytest==8.3.5
      - pytest-asyncio==0.26.0
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - pytest-xdist==3.6.1
      - pyyaml==6.0.2
      - six==1.17.0
      - toml==0.10.2
      - tomli==2.2.1
      - typing-extensions==4.13.0
      - virtualenv==20.29.3
      - zipp==3.21.0
prefix: /opt/conda/envs/pre-commit

tests/commands/try_repo_test.py::test_try_repo_staged_changes tests/xargs_test.py::test_xargs_propagate_kwargs_to_cmd
tests/commands/try_repo_test.py::test_try_repo_with_specific_hook tests/commands/try_repo_test.py::test_try_repo_relative_path tests/xargs_test.py::test_environ_size[env0-0] tests/xargs_test.py::test_environ_size[env1-12] tests/xargs_test.py::test_environ_size[env2-13] tests/xargs_test.py::test_environ_size[env3-24] tests/xargs_test.py::test_partition_trivial tests/xargs_test.py::test_partition_simple tests/xargs_test.py::test_partition_limits tests/xargs_test.py::test_partition_limit_win32_py3 tests/xargs_test.py::test_partition_limit_win32_py2 tests/xargs_test.py::test_partition_limit_linux tests/xargs_test.py::test_argument_too_long_with_large_unicode tests/xargs_test.py::test_partition_target_concurrency tests/xargs_test.py::test_partition_target_concurrency_wont_make_tiny_partitions tests/xargs_test.py::test_argument_too_long tests/xargs_test.py::test_xargs_smoke tests/xargs_test.py::test_xargs_negate tests/xargs_test.py::test_xargs_negate_command_not_found tests/xargs_test.py::test_xargs_retcode_normal tests/xargs_test.py::test_xargs_concurrency tests/xargs_test.py::test_thread_mapper_concurrency_uses_threadpoolexecutor_map tests/xargs_test.py::test_thread_mapper_concurrency_uses_regular_map
pre_commit/git.py pre_commit/commands/try_repo.py pre_commit/xargs.py
pre_commit/git.py pre_commit/commands/try_repo.py pre_commit/xargs.py