简体   繁体   English

Windows WSL2 和 git

[英]Windows WSL2 and git

I'm using WSL2, everything seems ok except that the files in Windows are not synced within WSL, what I mean by that is, if I navigate to a git repo (folder) and run git status , I see two different results inside WSL console and Windows Powershell, the WSL result is incorrect.我正在使用 WSL2,除了 Windows 中的文件未在 WSL 中同步之外,一切似乎都很好,我的意思是,如果我导航到 git 存储库(文件夹)并运行git status中的两个不同结果控制台和 Windows Powershell,WSL 结果不正确。

result from Powershell结果来自 Powershell

nothing to commit, working tree clean

result from WSL WSL 的结果

Changes not staged for commit:
  modified:   .gitattributes
  modified:   .github/ISSUE_TEMPLATE.md
  modified:   .github/ISSUE_TEMPLATE/bug.md
  modified:   .github/ISSUE_TEMPLATE/feature.md
  modified:   .github/ISSUE_TEMPLATE/question.md
  modified:   .github/ISSUE_TEMPLATE/regression.md
  modified:   .github/PULL_REQUEST_TEMPLATE.md
  modified:   .gitignore
  modified:   .travis.yml
  modified:   Analytics.md
  modified:   CODE_OF_CONDUCT.md
  modified:   CONTRIBUTING.md
  modified:   LICENSE.md
  modified:   MAINTAINERS
  modified:   README.md
  modified:   SECURITY.md

There are a lot of changes to commit I just copied the first few lines

How can it be fixed?如何修复?

I had this issue with WSL1, but it's gone with WSL2 actually.我在 WSL1 中遇到了这个问题,但实际上 WSL2 已经解决了。 The issue reproduced in case I used git clone inside Linux machine but then opened this folder from Windows host.如果我在 Linux 机器中使用git 克隆但随后从 Windows 主机打开此文件夹,则会重现该问题。 IDEA hasn't recognised that the folder has any git initiated repo. IDEA 没有识别出该文件夹有任何 git 启动的 repo。 I guess it was something with permissions to .git folder over the sharing stack (not sure is it samba or something else).我猜这是对共享堆栈上的.git文件夹具有权限的东西(不确定是samba还是其他东西)。 After I switched my distribution to WSL2 everything became fine.在我将发行版切换到 WSL2 后,一切都变得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM