includeIf个人和工作资料不起作用

includeIf个人和工作资料不起作用

本文介绍了Git includeIf个人和工作资料不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索这个问题,尝试从不同的来源尝试不同的方法...但这是行不通的.

I've been googling about this, trying different methods from different sources... but it doesn't work.

除非我在工作文件夹中,否则我要使用我的个人资料(用"git config --global user.email ..."定义)来推送提交.

I want to push commits with my personal profile (defined with "git config --global user.email ...") unless I'm on my work folder.

.gitconfig的内容位于C:/Users/my-user/

The content of my .gitconfig is located at C:/Users/my-user/

[user]
    name = Personal
    email = [email protected]

[includeIf "gitdir: F:/Work/CompanyName/"]
    path = F:/Work/CompanyName/.gitconfig-work

.gitconfig工作的内容位于F:/Work/CompanyName/

Content of my .gitconfig-work is located at F:/Work/CompanyName/

[user]
    name = Work
    email = [email protected]

当我从位于以下位置的工作转到克隆的存储库时:

When I go to a cloned repository from work located at:

F:/Work/CompanyName/Project

我使用:

git config --show-origin --get user.email

它显示:

file:C:/Users/<my-user>/.gitconfig

代替我定义的工作路线.

Instead of the route I defined to work.

感谢您的帮助.

推荐答案

您需要在以下位置删除一个空格:

You need to remove one space in:

[includeIf "gitdir: F:/Work/CompanyName/"]

即,将其读为:

[includeIf "gitdir:F:/Work/CompanyName/"]

请注意,在gitdir之后的冒号和要测试的路径名之间没有空格.

Note the lack of a blank between the colon after gitdir and the path name to be tested.

(您的Git至少也需要版本2.13.您可能会考虑使用gitdir/i:f:/work/companyname/,以便此处不区分大小写,前提是您的主机系统也不区分大小写,如F:部分所示. )

(Your Git also needs to be at least version 2.13. You might consider using gitdir/i:f:/work/companyname/ so that you are not case-sensitive here, assuming your host system is also not case-sensitive, as the F: part suggests.)

这篇关于Git includeIf个人和工作资料不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 00:54