开发者

Unlink of file Failed. Should I try again?

开发者 https://www.devze.com 2023-01-29 06:45 出处:网络
Something wrong is going on with one of the files in my local git repository. When I\'m trying to change the branch it say开发者_StackOverflow中文版s:

Something wrong is going on with one of the files in my local git repository. When I'm trying to change the branch it say开发者_StackOverflow中文版s:

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

What could that mean?


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.

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.

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.


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


this solution from here worked 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.


I encountered this issue while doing a git pull.

I tried git gc and it resolved my problem.


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:

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.


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 gc as mentioned by others.

This did the magic for me.


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

What git gc will do ?

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

When to run 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.

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 config --global gc.auto 0


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

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

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


I tried git gc and it resolved my problem.


I got this problem in Windows. I closed my IDE (Android Studio) and selected YES in git shell. It worked.


I was able to solve this by opening Powershell as Administrator and from there git checkout <branch_name>


On Windows 8: I ran git gc and it said git gc was already running, I ran git gc --force and the garbage collector ran.

I could then switch branches and merge without any issues, try git gc --force.

Perhaps the gc process didn't stop gracefully for one reason or another.


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

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.


I had this issue with .tmp files in /.git/objects/pack folder. I think something had failed during a push or pull, so I removed these temporary files and reset the HEAD to my last commit. Not sure if this is advised but it worked for me. Also git count-objects -v gave me a list of the .tmp files that didn't belong in the pack folder.

Or to suppress the y/n messages in windows git open cmd.exe and run:

SETX GIT_ASK_YESNO false

seen here: https://twitter.com/petercamfield/status/494805475733807104


After trying various solutions finally git clean -f helped me.

EDIT: I hit the problem again few times - closing all processes dependent on git seems to help (like gitbash, Eclipse IDE, etc.)


I ran into this issue in Windows, you might want to run the git bash as an administrator and then perform the desire commands, that solved the issue for me.


I faced same issue while doing 'git pull'. I tried manual housekeeping git command 'git gc' and it resolved my problem.


After run command

git rm -rf foo.bar

I see error

Unlink of file 'foo.bar' failed. Should I try again? (y/n)

Because another program is using this file. For example, when I run Java web application in debug model or run web application on server, I can't delete log file. Turn off application sever (or turn off debug process), re-try

git rm -rf foo.bar

I see file has been deleted.


I ran into this issue running git Bash and Eclipse EGit at the same time. Solution: close Eclipse. Also wouldn't hurt to run git gc as @khilo mentioned.


As stated above, something else is holding the files. Thing is that program doesnt look suspicious for us. I was trying to do a git pull from console, while having GitKraken opened. Closing GitKraken fixed the problem.


If you're using Docker and running Windows 10, you may want to stop the container(s) where the file may be running at. To show the statuses of your containers, run

docker ps -a

To stop them, simply run

docker stop <container name or container id>

This worked for me as I am running my local files using a .sh file


if your os host is linux/unix-like, you can run git gc --force to stop the file handler which take use of git files,

else if you're working on windows, you can stop git process by Task Manager or Process Manager. It seems that there are another git process taking use of your git files. Just kill the git process


This may be a separate gitk window running to see some git history.

Just close that window to fix that problem.


After none of the above answers seemed to work, running git fetch -p did the job for me.

https://git-scm.com/docs/git-fetch


I had the same issue while doing a git pull and as stated above, it was because of a program that was holding those files and was not allowing a git pull. Closing the program helped. Usually, the IDE (like Eclipse) from where the files are being checked-in will be holding it in the background. Closing the same and re-running git pull solved the problem for me.


I had this same error and closing the app which had the file open solved it. I was able to go back and press "Y"


If you are developing a web application, a common reason is to forget shutting down the server. For example this could be a simple Node.js process, or on windows your IIS process running more unobtrusive as background process.


I tried every single tip on this page and nothing helped. I was doing a git fetch and a git reset --hard origin/development gave me the unkink error. I couldn't reset to the latest commit.

What helped was checking out another branch and then checking out the previous branch. Very strange but it solved the problem.


If closing your IDE and running various git commands listed here won't help, try manually killing all running Java processes. I had a Java process probably left over from eclipse that somehow kept a configuration file open.


Worked for me, Tried on windows:

Stop your server running from IDE or close your IDE

Intellij/Ecllipse or any, it will work.

0

精彩评论

暂无评论...
验证码 换一张
取 消