Git rename from index.lock to index failed

前端 未结 16 2001
遇见更好的自我
遇见更好的自我 2020-11-30 06:42

Using the GitHub Windows client I did a sync to pull remote changes to my local machine, but before finishing the sync, I ran out of disk space and the sync failed.

相关标签:
16条回答
  • 2020-11-30 06:56

    I had a similar issue with Git. The solution for me was to delete the solution locally through windows explorer, and then re-clone the repository. This removed all the files that were stored locally on my machine, and resulted in the

    Rename from '.git/..' to '.git/..' failed. Should I try again? (y/n) y
    

    going away. After I cloned the respository, I tried my command again(which in my case was GIT COMMIT) and the failure did not reoccur.

    The issue came about when I was trying to resolve a merge conflict that was happening after merging a feature branch into the develop branch.

    0 讨论(0)
  • 2020-11-30 06:57

    Git 2.10 (Q3 2016, 4 years later) should improve the situation on Windows

    See commit 05d1ed6 (23 Aug 2016) by Ben Wijen (Ben).

    mingw: ensure temporary file handles are not inherited by child processes

    When the index is locked and child processes inherit the handle to said lock and the parent process wants to remove the lock before the child process exits, on Windows there is a problem: it won't work because files cannot be deleted if a process holds a handle on them.

    The symptom:

    Rename from 'xxx/.git/index.lock' to 'xxx/.git/index' failed.
    Should I try again? (y/n)
    

    Spawning child processes with bInheritHandles==FALSE would not work because no file handles would be inherited, not even the hStdXxx handles in STARTUPINFO (stdin/stdout/stderr).

    Opening every file with O_NOINHERIT does not work, either, as e.g. git-upload-pack expects inherited file handles.

    This leaves us with the only way out: creating temp files with the O_NOINHERIT flag. This flag is Windows-specific, however.
    For our purposes, it is equivalent to O_CLOEXEC (which does not exist on Windows), so let's just open temporary files with the O_CLOEXEC flag and map that flag to O_NOINHERIT on Windows.

    0 讨论(0)
  • 2020-11-30 07:00

    I was seeing this Rename from '.git/index.lock'... message when attempting to execute

    git checkout -b my-branch

    The fix for me was to run the command line as admin.

    Specifically I was using the excellent cmder application as a non-admin, which resulted in the rename message appearing. By running cmder as an admin, then performing the checkout again, it worked fine.

    0 讨论(0)
  • 2020-11-30 07:00

    For me it was this error:

    Rename from 'D:/dev/repo/.git/refs/remotes/origin/my-branch.lock' to 'D:/dev/repo/.git/refs/remotes/origin/my-branch' failed. Should I try again? (y/n)

    Renamed "my-branch" file, retried, and "my-branch.lock" succeed in renaming, not sure if this is correct, but worked. Local changes in both master and my-branch were preserved.

    0 讨论(0)
  • 2020-11-30 07:00

    I had seem issue when I was rebase my branch with master. My solution is turn off all solution which are opening and reset hard my branch to origin and rebase again.

    0 讨论(0)
  • 2020-11-30 07:03

    Either kill the process that is locking the file or if it is a new repo, del the .git folder rm -rf .git and start again with git init

    0 讨论(0)
提交回复
热议问题