-->

Git error - unable to unlink old 'some/file/na

2020-02-24 07:35发布

问题:

When trying to switch/checkout (in TortoiseGit) to another branch, I get the following error:

error: unable to unlink old 'foo/bar.cfc' (Bad file descriptor)

What does this mean?

回答1:

Are you using any other tools while using TortoiseGit?

For instance, this project mentions an interaction with Visual Studio:

If you see errors about being unable to unlink old files when running git commands on Windows, it's quite likely that you have the chrome solution open in Visual Studio and it's updating IntelliSense, which will briefly lock files at random.
The workaround is either to disable IntelliSense entirely, or to be sure to close the solution temporarily while performing any git operations which could touch a large number of files.

In other word, does the problem persists if you close as many currently running applications as you can?
Would TortoiseGit allow you to checkout another branch then?



回答2:

I ran into this problem-Eclipse was locking the file even though it wasn't open in the editor. Once I closed eclipse I could checkout fine.



回答3:

The file is locked by another program and cannot be overwritten. See what application has the file locked, close that application, and try again.



回答4:

If your problem is based on eclipse locking file, you can start your eclipse with -Dosgi.locking=none. I ran into this problem with eclipse Luna 4.4.0



回答5:

I got same error with github desktop app when i try to pull. I solved it by closing visual studio and running github desktop app in admin mode.