Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git rebase got 'unlink of file failed' error

Tags:

Using msysgit 1.7.0.2, when doing git rebase -i, it hangs and there's no message.
After enter ctrl+c, I can see

'unlink of file failed, should I try again (y/n)?' 

Then I tried git rebase --abort but got same error message. So now it's stuck in the middle of rebase process. This error seems to be caused by read-only file.

Is there any way to resolve this issue?

like image 291
Stan Avatar asked Sep 13 '10 07:09

Stan


People also ask

What is git gc?

The git gc command is a repository maintenance command. The "gc" stands for garbage collection. Executing git gc is literally telling Git to clean up the mess it's made in the current repository. Garbage collection is a concept that originates from interpreted programming languages which do dynamic memory allocation.


2 Answers

Did you try with set GIT_ASK_YESNO=false?

This Google group thread mentions it in the recent mingw evolutions:

Make use of the new environment variable GIT_ASK_YESNO to support the recently implemented fallback in case unlink, rename or rmdir fail for files in use on Windows.

What exact version of Git for windows are you using?
Note: msysgit setup is not the same than the "Git for Windows" setup, see also "Different between msysgit and cygwin + git ?")


git 2.8.4 (June 2016) does mention issue 755 which should also alleviate the issue (commit 2db0641):

Make sure temporary file handles are not inherited by child processes


See also Git 2.19 (Q3 2018): "Git - Unlink of file .idx and .pack failed (The only process owned handle to this file is git.exe)".

like image 179
VonC Avatar answered Sep 23 '22 00:09

VonC


I don't know if it applies in your situation, but I've just had a similar situation with 1.7.10.msysgit.1 (talking to a network share on an Ubuntu server). In my case, a failed merge had made several objects owned by root with permissions -r--rwSr--. A simple SSH login and

sudo chown steve: .git/* 

fixed one problem (for my user - unless you're called steve, you'll need to change that to your username!), and

chmod -R 0755 .git/* 

fixed the other.

like image 45
Steve Almond Avatar answered Sep 22 '22 00:09

Steve Almond