You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Git跨盘符配置失效:D盘FAT32分区无法加载指定用户配置

跨盘符Git多用户配置失效问题(FAT32分区场景)

问题现象

  • C盘(NTFS格式)的个人文件夹下,Git仓库可正常加载personal@email.com的用户配置
  • D盘(FAT32格式)的工作文件夹下,Git仓库无法加载work@email.com配置,始终使用全局.gitconfig中的default@email.com

疑问

  1. 这种跨盘符的多场景用户配置是否可行?
  2. Git是否要求仓库与Git exe位于同一盘符?
  3. 求成功实现跨盘符多用户配置的案例及解决方法

配置文件详情

全局.gitconfig配置(调换includeIf顺序无变化)

[user]
    email = default@gmail.com
    name = Default

[includeIf "gitdir/i:D:/Work/**"]
    path = ~/.gitconfig-work
[includeIf "gitdir/i:C:/Personal/**"]
    path = ~/.gitconfig-personal

.gitconfig-work配置

[user]
    email = work@email.com
    name = Work

.gitconfig-personal配置

[user]
    email = personal@email.com
    name = Personal

配置有效性验证

曾将.gitconfig-work关联到C盘路径,可正常加载work@email.com,说明配置文件本身无问题:

[includeIf "gitdir/i:C:/Personal/**"]
    path = ~/.gitconfig-work 

测试结果

个人文件夹(正常加载配置)

PS C:\Personal> mkdir test

    Directory: C:\Personal

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----           10/2/2023 12:17 AM                test

PS C:\Personal> cd .\test\
PS C:\Personal\test> git init
Initialized empty Git repository in C:/Personal/test/.git/
PS C:\Personal\test> git config --show-origin --get user.email
file:C:/Users/Sacha/.gitconfig-personal        personal@email.com

工作文件夹(配置失效)

PS D:\Work> mkdir test

    Directory: D:\Work

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----           10/2/2023 12:16 AM                test

PS D:\Work> cd .\test\
PS D:\Work\test> git init
Initialized empty Git repository in D:/Work/test/.git/
PS D:\Work\test> git config --show-origin --get user.email
file:C:/Users/Sacha/.gitconfig  default@gmail.com

补充信息

  • D盘为物理独立硬盘的FAT32分区,需与Pop OS 22.04共享,无法更换分区格式或调整盘符
  • 环境信息:
    Git : git version 2.40.1.windows.1
    Windows Version: 22H2
    
  • 曾尝试将D盘映射为C盘下的Shared路径,问题仍未解决

内容的提问来源于stack exchange,提问作者Sacha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 19:12:14