Git 根据不同目录设置不同账号

Git 根据不同目录设置不同账号

includeIf 配置

shell 复制代码
# 先创建 gitconfig 文件(如果不存在)
touch ~/.gitconfig
touch ~/.gitconfig_pers
touch ~/.gitconfig_work
shell 复制代码
# ~/.gitconfig

[core]
	longpaths = true # 允许处理长路径

# includeIf 的 gitdir 条件只会在实际 Git 仓库中生效,普通的文件目录不会触发条件包含
[includeIf "gitdir:C:/LouisPers/"] # 注意目录结尾不要少了 /,代表是个目录
    path = ~/.gitconfig_pers

[includeIf "gitdir:C:/LouisWork/"] # 注意目录结尾不要少了 /,代表是个目录
    path = ~/.gitconfig_work
shell 复制代码
# ~/.gitconfig_pers

[user]
    name = your_pers_name
    email = your_pers_email@example.com
shell 复制代码
# ~/.gitconfig_work

[user]
    name = your_work_name
    email = your_work_email@company.com
相关推荐
sTone873752 分钟前
Zygote的第一性理解
android
sTone873756 分钟前
类RN框架通过Service暴露卡片渲染能力给AI Chat
android·react native
灯火不休6 分钟前
Android Studio & Flutter 构建命令完全指南
android
杉氧8 分钟前
Ktor 全栈之路 (5):JWT 认证全流程实战 —— 打造安全通信闭环
android·架构·kotlin
️学习的小王30 分钟前
Python + MySQL 学生信息管理系统实战教程
android·python·mysql
帅次36 分钟前
Android 高级工程师面试:Flutter 路由导航 近1年高频追问 18 题
android·flutter·面试
alexhilton9 小时前
MVI模式的完整历史、误解和现代Android范式
android·kotlin·android jetpack
心中有国也有家14 小时前
AtomGit Flutter 鸿蒙客户端:Canvas 绘制进阶-路径、渐变与混合模式
android·javascript·flutter·华为·harmonyos
hunterandroid16 小时前
WorkManager 可靠性实战:唯一任务、重试与幂等设计
android·前端
程序员老刘16 小时前
Android 17的10个AI功能,国内用户真正能用的有几个?
android·flutter·ai编程