gpt4 book ai didi

git - 在 Windows 和 WSL 之间共享 git repo 符号链接(symbolic link)

转载 作者:行者123 更新时间:2023-12-03 00:16:42 27 4
gpt4 key购买 nike

我有以下设置:

  • WSL 与 Ubuntu 一起安装,并且已经安装了 git
  • git 从 https://git-scm.com 安装在 Windows 端
  • 通过打开开发者模式并将我的用户添加到正确的策略组来启用符号链接(symbolic link)创建,如 https://github.com/git-for-windows/git/wiki/Symbolic-Links 中所述。
  • core.symlinks=true(由于上面的行)
  • core.autocrlf=false (我不想让 git 做任何小聪明,我在 Windows 和 WSL 之间共享存储库)

几乎工作完美(印象深刻)。当我克隆存储库时,在 Windows 和 WSL 中都一切正常,除了两侧之一的符号链接(symbolic link)说它们已被修改,但实际上并未修改。两边的符号链接(symbolic link)都可以正常工作,我可以毫无问题地导航它们。

初始克隆(在 Windows 端)后,Windows PowerShell 会提供:

PS C:\Users\Matthew\Projects\...> git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

但是在 WSL 方面,它表示两个符号链接(symbolic link)已修改:

/mnt/c/Users/Matthew/Projects/...$ git status 
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: t/browser
modified: web/jslib

no changes added to commit

但是 git diff 没有给出输出:

/mnt/c/Users/Matthew/Projects/...$ git diff
/mnt/c/Users/Matthew/Projects/...$

如果我随后重置 WSL 端的 checkout ,一切都会切换:

/mnt/c/Users/Matthew/Projects/...$ git reset --hard HEAD 
HEAD is now at ......... Commit message here
/mnt/c/Users/Matthew/Projects/...$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

回到 Windows Powershell:

PS C:\Users\Matthew\Projects\...> git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: t/browser
modified: web/jslib

no changes added to commit (use "git add" and/or "git commit -a")
PS C:\Users\Matthew\Projects\...> git diff
PS C:\Users\Matthew\Projects\...>

看起来 git 正在设置一个内部标志,然后它认为该标志在其他系统中发生了更改;有什么办法可以解决或解决这个问题吗?

最佳答案

找到了解决方法。我在 wsl 中为 Windows 的 Git 创建了别名:alias git="/mnt/c/Program\Files/Git/bin/git.exe"。完美运行!

关于git - 在 Windows 和 WSL 之间共享 git repo 符号链接(symbolic link),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56504821/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com