'Unlink of file failed [duplicate]

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.



Solution 1:[1]

This is a Windows specific answer, so I'm aware that it's not relevant to you... I'm just including it for the benefit of future searchers.

In my case, it was because I was running Git from a non-elevated command line. "Run as Administrator" fixed it for me.

Solution 2:[2]

For me, it was because Visual Studio was trying to reload all of the changed files from the pull. Have visual studio refresh, then run git gc.

Solution 3:[3]

On Windows using GitHub for Windows, I got a similar error in the shell when running git gc:

Unlink of file '.git/objects/pack/pack-0b40ae7eae9b83edac62e19c07ff7b4c175244f6.idx' failed. Should I try again? (y/n)

I solved it by closing the GitHub GUI.

Solution 4:[4]

Try to restart you Apache or other web server as it may have locked some of your files.

Solution 5:[5]

Closed Visual Studio and Rubymine and didn't get the error again. One of them was the culprit.

Solution 6:[6]

Close your IDE then do git pull . It will work.

Solution 7:[7]

I've got this problem too, but I found out it was the UltraEdit in the way, since I used UE to organize and edit my eclipse workspace~~

Maybe because the UE has a handle on the old version of specific file, Git could not unlink of it.

After I closed UltraEdit, the problem never happened again.

Solution 8:[8]

This was caused in my case by SimpLESS, the LESS compiler. You have to close it in the systray.

Solution 9:[9]

None of the above answers ain't work for me, but I run git gc command with force option, and it solved my case.

'git gc --force'

[Windows 7, Run As Administrator => Command Prompt]

Solution 10:[10]

The problem is because you're having some program that handling these files. I have an suggestion that you should use the Unlocker to find the program that's handling it:

Unlocker

Solution 11:[11]

I have had this happen on Windows XP, both with the message stuck in a loop, and being able to be cleared by replying.

The stuck-in-a-loop occurence was cleared by closing the Git-GUI. (I was running git merge -i in a bash shell.)

The other occurences happened possibly due to the large number of files in my repository. It happened mainly with .cod files, which I later exclude from version control. (I do have a reason for intially tracking them.) I believe the cause might be related to the rate at which Git uses file handles.

I wonder if the able-to-be-cleared-by-replying problem is Windows related, as two previous posters have mentioned Windows, and no one has said they have the problem with other operating systems.

Solution 12:[12]

I had PHPStorm open, closed that and all was well.

Solution 13:[13]

I had the same issue and I closed all the related programs from Window Task Manager. However, it was still not working. The interesting part is that I ran "Git rebase" instead of "Git pull" and it worked!

Solution 14:[14]

Try running command line editor in administrative mode and run command. It helps and solves problem. :)

Solution 15:[15]

In my case I had an old method of pruning tags causing the issue. I solved it by unsetting the original:

git config --global --unset remote.origin.fetch '\+refs/tags/\*:refs/tags/\*'

then adding this to prune deleted branches on the server:

git config --global fetch.pruneTags true

Solution 16:[16]

I faced the same error and resolved it by closing the eclipse and pulling again as the file was being used.

Solution 17:[17]

I had the same issue on windows. I was trying to run gc on windows while the file was being accessed on my Ubuntu VM. Closed Terminator and File explorer on Ubuntu worked for me.