marko marko - 2 months ago 9x
Git Question

Unlink of file failed

I'm trying to do a git pull and I get the following error:

Unlink of file 'lib/xxx.jar' failed. Should I try again? (y/n)

No matter if I select y or n it's not possible to get to a state where I can pull or push.


That usually means a process is still using that specific file (still has an handle on it)
(on Windows, ProcessExplorer is good at tracking that kind of process)

Try closing your other programs, and try again your git pull.

Note that you have an alternative with the GIT_ASK_YESNO variable.

Update January 2016

That should be fixed in Git 2.8 (March 2016)

See commit d562102, commit dcacb1b, commit df617b5, commit 0898c96 (13 Jan 2016) by Johannes Schindelin (dscho).
(Merged by Junio C Hamano -- gitster -- in commit 3c80940, 26 Jan 2016)

fetch: release pack files before garbage-collecting

Before auto-gc'ing, we need to make sure that the pack files are released in case they need to be repacked and garbage-collected.

Many codepaths that run "gc --auto" before exiting kept packfiles mapped and left the file descriptors to them open, which was not friendly to systems that cannot remove files that are open.
They now close the packs before doing so.

That fixes git-for-widows issue 500.

Looking at the test used to validate that new approach, a possible workaround (since Git 2.8 is not yet out) would be to raise artificially gc.autoPackLimit.

git config gc.autoPackLimit 10000
git fetch
git config gc.autoPackLimit 50 # default value

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