VSCode 在 WSL1 上未检测到 git 回购
VSCode on WSL1 doesn't detect git repo
我在 WSL1 上 运行 VSCode,我的 git 存储库未被 VSCode 识别。
我检查过:
- Git --版本: 2.32.0
2.17.1
- VSCode版本:1.58.1
- Git SCM 扩展已禁用然后重新启用
- git 在设置中设置的路径和扫描存储库
None 这些似乎有所不同,但关闭和重新打开 VSCode 可能工作 10 次或更少。
如何在不重新加载的情况下 git 被识别?
先尝试升级 Git(在 Windows 和 Linux WSL1 VM 上,使用 - ppa 升级至少会升级到 2.31或 2.32.)
考虑使用 Visual Studio Code Remote - WSL 扩展来更可靠地访问您的 Git 存储库。
我的 git 存储库似乎损坏了 git 对象,我必须在 VSCode 识别它之前清理这些对象。我使用 commands here(假设你在 master
)这样做,目前是:
rm -fr .git
git init
git remote add origin [your-git-remote-url]
git fetch
git reset --mixed origin/master
git branch --set-upstream-to=origin/master master
请注意,自 2021 年 8 月 13 日起,[git-remote-url] 应该看起来像 git@github.com:user/repo.git
。要设置它,请参阅 Connecting to GitHub with SSH
我在 WSL1 上 运行 VSCode,我的 git 存储库未被 VSCode 识别。
我检查过:
- Git --版本: 2.32.0
2.17.1 - VSCode版本:1.58.1
- Git SCM 扩展已禁用然后重新启用
- git 在设置中设置的路径和扫描存储库
None 这些似乎有所不同,但关闭和重新打开 VSCode 可能工作 10 次或更少。
如何在不重新加载的情况下 git 被识别?
先尝试升级 Git(在 Windows 和 Linux WSL1 VM 上,使用
考虑使用 Visual Studio Code Remote - WSL 扩展来更可靠地访问您的 Git 存储库。
我的 git 存储库似乎损坏了 git 对象,我必须在 VSCode 识别它之前清理这些对象。我使用 commands here(假设你在 master
)这样做,目前是:
rm -fr .git
git init
git remote add origin [your-git-remote-url]
git fetch
git reset --mixed origin/master
git branch --set-upstream-to=origin/master master
请注意,自 2021 年 8 月 13 日起,[git-remote-url] 应该看起来像 git@github.com:user/repo.git
。要设置它,请参阅 Connecting to GitHub with SSH