git 取消文件链接失败。我应该再试一次吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4389833/
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-10 09:37:27  来源:igfitidea点击:

Unlink of file Failed. Should I try again?

gitunlink

提问by Pol

Something wrong is going on with one of the files in my local git repository. When I'm trying to change the branch it says:

我本地 git 存储库中的一个文件出现问题。当我尝试更改分支时,它说:

Unlink of file 'templates/media/container.html' failed. Should I try again? (y/n)

What could that mean?

那是什么意思?

回答by Melissa

This could mean that another program is using the file, which is preventing git from "moving" the file into or out of the working directory when you are attempting to change branches.

这可能意味着另一个程序正在使用该文件,这会阻止 git 在您尝试更改分支时将文件“移入”或移出工作目录。

I have had this happen on Windows Vista where eclipse is the program "using" the file. The file may not be actually open in eclipse but may have been opened by a process run by eclipse.

我在 Windows Vista 上发生过这种情况,其中 eclipse 是“使用”文件的程序。该文件可能实际上并未在 eclipse 中打开,但可能已被 eclipse 运行的进程打开。

In this event, try closing the file in any applications that might have used it. If that doesn't work, completely exit any applications which may have opened the file.

在这种情况下,请尝试在任何可能使用过该文件的应用程序中关闭该文件。如果这不起作用,请完全退出任何可能打开文件的应用程序。

回答by khilo

I had this issue and solved it by the command : git gcThe above command remove temp and unnecessary files. (Garbage collector.)

我遇到了这个问题并通过命令解决了它:git gc上述命令删除临时文件和不必要的文件。(垃圾收集器。)

回答by sepehr

this solution from hereworked for me:

从该解决方案在这里对我来说有效:

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.

这是一个特定于 Windows 的答案,所以我知道它与您无关......我只是为了将来的搜索者的利益而包含它。

就我而言,这是因为我从非提升的命令行运行 Git。“以管理员身份运行”为我修复了它。

回答by Rahul Chandran

I encountered this issue while doing a git pull.

我在执行git pull.

I tried git gcand it resolved my problem.

我试过了git gc,它解决了我的问题。

回答by andhdo

In my case there are no processes touching the file or directory. Maybe it happens if the path is very long, because an operating system restriction (windows). Try enabling the longpath support flag in the global git configuration as indicated below:

就我而言,没有进程接触文件或目录。如果路径很长,可能会发生这种情况,因为操作系统限制(Windows)。尝试在全局 git 配置中启用 longpath 支持标志,如下所示:

git config --global core.longpaths true

or try to setting the yes/no answer flag if it is not conflictive for you

或尝试设置是/否回答标志,如果它对您没有冲突

set GIT_ASK_YESNO=false

If the path is too long, I've not found a successful solution.

如果路径太长,我还没有找到成功的解决方案。

回答by Mukesh Yadav

I tried git gcand it resolved my problem.

我试过了git gc,它解决了我的问题。

回答by Ramesh Papaganti

As i am using gitkrakenand command prompt, i ran into the same issue. And then i run git gccommand it resolved my problem. So i am happy and want share some of the points which might be helpful.

当我使用gitkraken和命令提示符时,我遇到了同样的问题。然后我运行 git gc命令它解决了我的问题。所以我很高兴,并想分享一些可能有帮助的观点。

What git gcwill do ?

怎么git gc会呢?

git gcremoving unreachable objects which may have been created from prior invocations of git add.

git gc删除之前调用 git add 时可能创建的无法访问的对象。

When to run git gc?

什么时候跑git gc

From doc, users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance.

doc,鼓励用户在每个存储库中定期运行此任务,以保持良好的磁盘空间利用率和良好的操作性能。

How to make it auto-configurable?

如何让它自动配置?

Some git commands may automatically run git gc; see the --auto flag below for details. If you know what you're doing and all you want is to disable this behavior permanently without further considerations, just do

一些 git 命令可能会自动运行 git gc;有关详细信息,请参阅下面的 --auto 标志。如果您知道自己在做什么并且只想永久禁用此行为而无需进一步考虑,请执行以下操作

git config --global gc.auto 0

回答by papigee

This might be useful for someone; if all the above didn't work for you, follow these steps:

这可能对某人有用;如果以上所有方法都不适合您,请按照以下步骤操作:

  1. Close your IDE (mine was Eclipse, not sure if it applies to Intellij and others) or any other app that might be using git.

  2. Open git from the command line (in my case I had git bash) and run git gcas mentioned by others.

  1. 关闭您的 IDE(我的是 Eclipse,不确定它是否适用于 Intellij 和其他人)或任何其他可能正在使用 git 的应用程序。

  2. 从命令行打开 git(在我的情况下,我有 git bash)并git gc按照其他人提到的方式运行。

This did the magic for me.

这对我来说很神奇。

回答by nickD

In my case (Win8.1, TortoiseGit running), it was the process called "TortoiseSVN status cache" that was locking the file.

在我的情况下(Win8.1,TortoiseGit 正在运行),正是名为“TortoiseSVN 状态缓存”的进程锁定了文件。

Killing it allowed me to run "git gc" without any more problems. The above process is fired up by TortoiseGit, so there is no need to manually restart it.

杀死它让我可以运行“git gc”而没有任何问题。上述过程由 TortoiseGit 启动,因此无需手动重启。

回答by jakub.g

I had this kind of issue on Windows 7 and it turned out to be due to some orphaned git.exeprocess.

我在 Windows 7 上遇到了这种问题,结果是由于一些孤立的git.exe进程。

To solve it, open Task Manager and kill all git.exeprocesses.

要解决它,请打开任务管理器并杀死所有git.exe进程。

Since gitcommands are short-lived, you should normally never see any git.exein Task Manager. When they are there, it usually means something is wrong, and you should kill those processes.

由于git命令是短暂的,您通常不会git.exe在任务管理器中看到任何命令。当它们在那里时,通常意味着出现问题,您应该终止这些进程。