GIT 拉取失败:“无法取消链接文件:参数无效”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45335949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:04:28  来源:igfitidea点击:

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

gitmoodleinvalid-argument

提问by pillsbur

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.

新 GIT 用户,在 Windows 服务器上管理 Moodle 课程网站系统。尝试对核心代码进行第一次 Pull 更新(使用 TortoiseGit),但它不起作用。由于“无效参数”,Git 无法取消链接任何要更新的 200 多个文件的旧版本。我不知道这意味着什么。

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

这是我关闭 210 个错误对话框后的样子: 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 greatlyappreciated!

任何想法将极大的赞赏!

回答by Nicolas Leucci

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 :)

希望这有助于某人:)

回答by Ahmed AMMOURI

I had the same issue with Visual Studio Code.
Try to close any other tools while using Tortoisegit

我有同样的问题Visual Studio Code
使用时尝试关闭任何其他工具Tortoisegit

回答by Zein Makki

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 Handlesand 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.

错误消息显示了 git 无法取消链接的文件名。在 Windows 中,您可以转到Start Menu > Resource Monitor > CPU tab > Associated Handles并搜索文件名(不是完整路径),然后您将获得进程锁定该文件的结果。就我而言,它是explorer.exe. 所以我终止了这个进程,git 再次按预期工作。

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

我想您可以通过查找锁定文件的进程来使用其他操作系统来做同样的事情。

回答by ivan866

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.

该问题与文件权限有关。在 Windows 7 上使用外部驱动器后会出现,然后再次在 Windows 10 上出现。尤其是将第一台计算机(即最先使用的计算机)置于休眠模式并打开应用程序是很危险的 - 在另一台计算机上使用这些文件但使用相同的应用程序后重新连接驱动器后,许多打开的文件可能会损坏。
可以用 CHKDSK /f 修复,但很可能会删除混乱的文件。

回答by fintechilla

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

我重新启动了我正在将“有问题”文件拉入的电脑,同时我关闭了另一台电脑上的 IDE,该电脑正在使用该文件并从中推送它。有效

回答by Michael Manley

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

尝试从 gitlab 中提取时,我也遇到了取消链接问题。

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

基于 ivan866 和 Nicolas Leucci 的回答,为了解决这个问题,我只是在管理模式下打开了我的 SourceTree,这解决了我的问题。我想 SourceTree 没有足够的权限来正确处理权限。总之值得一试!

回答by Alamakanambra

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

我在合并分支时遇到了这个问题。使用管理员权限打开 Powershell 并在那里执行合并有帮助。