Reputation: 1181
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!
Upvotes: 118
Views: 150279
Reputation: 226
I solved the issue by running Vs code as an administrator. I hope it should help someone (:
Upvotes: -1
Reputation: 103
It might be file being opened elsewhere (e.g. notepad). You can try using 'file locksmith' from PowerToys to find app using the file.
Upvotes: 2
Reputation: 17
In my case I added that folder for Windows Ransomware Protection and that locked the file and didn't allow the github to interact.
Upvotes: 0
Reputation: 659
If you are doing with terminal. Always Commit/Stash First so that you can hard reset to previous commits, to be able to take latest pull
Upvotes: 0
Reputation: 1
I solved this problem by deleting the local file that git can't unlink it, and it worked fine
Upvotes: 0
Reputation: 107
For me I had to close Unity. From now on I only use push/pull when Unity is closed.
Upvotes: 0
Reputation: 13
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.
Upvotes: 1
Reputation: 378
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.
Upvotes: 1
Reputation: 1421
I was running a program in InteliJ, and stopping it released the file. It worked afterwards
Upvotes: 2
Reputation: 665
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
.
Upvotes: 0
Reputation: 30052
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).
Upvotes: 52
Reputation: 7881
I had this issue while merging branches. Opening Powershell with admin rights and performing merge there helped.
Upvotes: 0
Reputation: 131
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!
Upvotes: 10
Reputation: 21
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
Upvotes: 2
Reputation: 582
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, i.e. 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.
Upvotes: 7
Reputation: 3359
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 :)
Upvotes: 265