我有两个键到不同的github帐户,并有配置~/.gitconfig
:
[user]
name = example
email = example@example.com
[pull]
rebase = true
[rebase]
autoStash = true
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[includeIf "gitdir/i:/Users/example/Documents/github_2/"]
[core]
sshCommand = "ssh -i ~/.ssh/github2_key"
然后,我去一个不在/Users/example/Documents/github_2/
的文件夹,运行git clone github1_private_project
,git告诉我Please make sure you have the correct access rights
它可以从/Users/example/Documents/github_2/
中的帐户'github2'中git克隆项目
git版本:
% git -v
git version 2.39.2 (Apple Git-143)
1条答案
按热度按时间fv2wmkja1#
includeIf
的语法应该是(参见文档):语法
实际上意味着
其中密钥
core.sshCommand
总是(无条件地)被定义。