← 返回首页
Repo.index.reset fails on windows · Issue #1630 · gitpython-developers/GitPython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Repo.index.reset fails on windows #1630

New issue
New issue

Description

How to reproduce

  1. clone any repo
  2. edit a tracked file
  3. in python, try to reset with
    Repo().index.reset(working_tree=True)
    You will get a stack trace.

Step by step recipe:

$ git clone https://github.com/gitpython-developers/GitPython git-python $ cd git-python $ python -m venv --prompt git venv $ .\venv\Scirpts\Activate.ps1 # or whatever script is appropriate for you $ rm pyproject.toml # make any edit $ git status -sb ## main...origin/main D pyproject.toml $ python >>> from git import Repo >>> repo.index.reset(working_tree=True) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\<user>\code\git-python\git\index\util.py", line 103, in check_default_index return func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\<user>\code\git-python\git\index\base.py", line 1320, in reset new_inst = type(self).from_tree(self.repo, commit) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\<user>\code\git-python\git\index\base.py", line 367, in from_tree repo.git.read_tree(*arg_list, **kwargs) File "C:\Users\<user>\code\git-python\git\cmd.py", line 739, in <lambda> return lambda *args, **kwargs: self._call_process(name, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user>\code\git-python\git\cmd.py", line 1312, in _call_process return self.execute(call, **exec_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\<user>\code\git-python\git\cmd.py", line 1107, in execute raise GitCommandError(redacted_command, status, stderr_value, stdout_value) git.exc.GitCommandError: Cmd('git') failed due to: exit code(128) cmdline: git read-tree --index-output=C:\Users\<user>\code\git-python\.git\tmpxnmxtmmu HEAD stderr: 'fatal: unable to write new index file'

Expectation

I was expecting the result would be the equivalent of git reset --hard HEAD. Am I doing something incorrectly here? I'm unfamiliar with Windows, so it's quite possible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Footer

      © 2026 GitHub, Inc.