我在公司工作中使用 gitlab.com,在个人工作中使用 github.com。我已经阅读了很多线程,很多关于身份问题的主题,但是,我仍然无法理解为什么它对我不起作用。
我有一个~/.ssh/config文件如下
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/perso_id_rsa
Host gitlab
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)
还有大师 ~/.gitconfig
[user]
email = my_company_address
name = my_company_name
[includeIf "gitdir:~/Workspace/perso"]
path = ~/Workspace/perso/.gitconfig
Run Code Online (Sandbox Code Playgroud)
而一个 ~/Workspace/perso/.gitconfig
[user]
email = my_perso_email
name = my_pseudo
Run Code Online (Sandbox Code Playgroud)
当我从 ~/Workspace/perso/my_perso_project 中的 perso 项目提交时,提交作者是我的公司地址(提交毫无问题地推送到 github)。
有人可以帮忙吗?
谢谢
你的 includeif 是错误的。gitdir:~/Workspace/perso不是.git目录,并且没有搜索标志。请参阅git configincludeif 的文档,
如果模式以 , 结尾
/,**将自动添加。例如,模式foo/ 变为foo/**。换句话说,它递归地匹配“foo”和里面的所有内容。
要么指定您要检查的特定 git 目录,要么告诉 Git 您指的是整个子树中的任何 git 目录:
[includeIf "gitdir:~/Workspace/perso/.git"]
path = ~/Workspace/perso/.gitconfig
Run Code Online (Sandbox Code Playgroud)
或者
[includeIf "gitdir:~/Workspace/perso/**"]
path = ~/Workspace/perso/.gitconfig
Run Code Online (Sandbox Code Playgroud)
或者
[includeIf "gitdir:~/Workspace/perso/"]
path = ~/Workspace/perso/.gitconfig
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
217 次 |
| 最近记录: |