0

Visual Studio 2022 (17.5.3) won't let me delete a local branch because it still thinks it is checked out in a local reposititory. However that repository does not exist anymore, the whole folder is gone. I deleted it and didn't think about the branch. The repository also doesn't show up in Visual Studio anymore. Except for the error message.

How can I fix this? Is there any other hidden or temp directory where Visual Studio stores the info? Is there any command I can run?

I tried various, even recreated the folder but ovbiously git fails because it doesnt detect any repository anymore, since the files are gone...

CSharpie
  • 9,195
  • 4
  • 44
  • 71

1 Answers1

1

If the error message is similar to this one (error: Cannot delete branch 'aBranchName' checked out at 'C:/path/to/repo'), then you need to check your git status first (outside of Visual Studio itself, in the local repository root folder)

You will see if you are in a worktree (as in "multiple working directories"), in which case you need to remove said working tree (git worktree remove).

The OP CSharpie confirms in the comments:

It was a worktree I deleted, not the repository, so I could use your command to delete that worktree in the actual repo.

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