简体   繁体   中英

GIT pull failed: 'unable to unlink file: invalid argument'

New GIT user here, managing a Moodle course web site system on a Windows server. Trying to do my first Pull update of the core code (using TortoiseGit) and it's not working. Git is unable to unlink old versions of any the 200+ files to be updated because of an "invalid argument". I have no idea what that means.

Here's what it looks like after I dismiss 210 error dialogs: tortoisegit

I've rebooted the server and scoured the web for ideas, but I'm at a loss for what to try next.

Any ideas would be greatly appreciated

I lost hours with that error too.

In my case, I got this error because some files was locked by another program . I had to close everything then I was able to pull again.

Hope this help someone:)

The error message shows the file name(s) that git was unable to unlink. In windows, you can go to Start Menu > Resource Monitor > CPU tab > Associated Handles and search for the file name (not the full path), then you will get a result of the process locking that file. In my case, it was explorer.exe . So I killed that process and git worked again as expected.

I guess you can do that same using other operating systems by finding the process(es) locking the file(s).

Try to close any other tools while using Tortoisegit

I also had unlink issues when trying to pull from gitlab.

Based on ivan866's and Nicolas Leucci's answer, to resolve I simply opened my SourceTree in administrative mode which fixed my problem. I suppose SourceTree didn't have enough rights to handle the permissions correctly. Anyway it's worth a try

The issue is connected with file permissions . Can appear after using the external drive on Windows 7, then on Windows 10 again. Especially it is risky to leave the first computer, ie the one used first, in hibernate mode with applications opened - many opened files can get corrupt after you reconnect the drive after using those files on another computer, but with same apps.
Can be healed with CHKDSK /f, but it is highly likely messed files will get deleted.

I rebooted the pc I was pulling the 'troubled' file into and at the same time I closed the IDE on my other pc which was using the very file and from which I had pushed it. It worked

I was running a program in InteliJ, and stopping it released the file. It worked afterwards

This issue happens if the solution is open in your IDE because the files are locked. Try to close the solution and then re-attempt the operation.

For me, I was getting:

"error: unable to unlink old 'Library/ArtifactDB': Invalid argument error: unable to unlink old 'Library/SourceAssetDB': Invalid argument fatal: Could not reset index file to revision 'HEAD'."

And as soon as I closed Unity Git was able to work normally. I think the Unity permissions must've made it go funny.

I had this issue while merging branches. Opening Powershell with admin rights and performing merge there helped.

In my case, despite restarting my computer and closing any IDE I had running, I STILL had the problem, and trying to run the git pull in sudo mode returned a different error. The solution was tu use (in local, so it wasn't a security issue) sudo chmod 777 path/to/folder/of/file and sudo chmod 777 path/to/folder/of/file/specificFile.ext .

For me I had to close Unity. From now on I only use push/pull when Unity is closed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM