vscode 源代码管理无法识别我的存储库

Mik*_*ink 3 git github visual-studio-code

我有一个本地存储库,它链接到一个旧的远程存储库。我在 GitHub 上创建了一个新的存储库并在文件夹中运行它

git remote set-url origin <new repo url>
Run Code Online (Sandbox Code Playgroud)

其中 url 是新的存储库。然后我跑了

git push -u origin master
Run Code Online (Sandbox Code Playgroud)

这将所有内容推到了我的新仓库中。如果我跑

git remote -v
Run Code Online (Sandbox Code Playgroud)

我得到了正确的仓库位置。但 vscode 似乎无法识别该存储库。意思是当前打开的文件夹没有 git repo。为什么是这样?我尝试运行 git init 打印

Reinitialized existing Git repository in <folder name/.git/>
Run Code Online (Sandbox Code Playgroud)

但这没有任何作用吗?

我该怎么做才能让 vscode 的源代码管理再次看到我的存储库?我有未提交的代码,因此并非所有内容都被推送,因此我不能简单地克隆存储库。

编辑:

当我尝试提交时出现以下错误

$ git commit -a -m "Renamed the repo"
fatal: this operation must be run in a work tree 
Run Code Online (Sandbox Code Playgroud)

Mik*_*ink 5

我必须进入 .git/config 并将工作树字段更新到新的文件夹位置。