44

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?

Yue Lin Ho
  • 2,945
  • 26
  • 36
Tariq Ahmed
  • 611
  • 2
  • 7
  • 12

6 Answers6

44

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?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
29

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.

Zach Wymer
  • 540
  • 9
  • 11
  • Any idea of how to fix this?! I suddenly started running into this problem when upgrading to Eclipse 4.4 (Luna), never had it before. – stolsvik Jul 09 '14 at 13:21
  • Like I said, once I closed Eclipse it worked fine. I would try the following: 1. Stop Eclipse 2. Open task manager to make sure Eclipse is really dead. 1. Restart your computer 2. Download a program like unlocker to try and unlock the file. Good luck! I hope one of these things helps you. Sorry, I have no idea how I can format comments on SO. – Zach Wymer Jul 09 '14 at 17:41
  • Eh.. It is NOT a solution to close Eclipse, I thought that was bloody obvious. And yes, I of course found out that Eclipse was the problem by closing Eclipse.. Evidently, one can start Eclipse with the switch "-Dosgi.locking=none", as @user3825263 points out. – stolsvik Jul 13 '14 at 23:01
  • 1
    I didn't even have to close Eclipse, just stop its embedded Tomcat. – Noumenon Jul 23 '18 at 15:36
  • When this issue happens, I could only resolve it by restarting my computer. Closing individual programs like Sourcetree and Android Studio won't help, at least in my case. – AndroidDev Jul 11 '19 at 07:48
21

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

Community
  • 1
  • 1
James Lawruk
  • 30,112
  • 19
  • 130
  • 137
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

victor
  • 41
  • 2
  • I finally downgraded my eclipse to kepler version. I ran into too much problems with maven, git and windows locking file system. – victor Jul 22 '14 at 08:11
1

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.

bthn
  • 176
  • 2
  • 13
0

Make a bat file with the below and run it. It will restart
explorer, which is the cause usually if not your IDE

taskkill /f /IM explorer.exe
start explorer.exe
exit
tichra
  • 557
  • 5
  • 18