I have two keys to different github account and there is the config ~/.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"
then, I go to a folder that did not at /Users/example/Documents/github_2/
, and run git clone github1_private_project
, git told me Please make sure you have the correct access rights
It works to git clone the project from account 'github2' in /Users/example/Documents/github_2/
git version:
% git -v
git version 2.39.2 (Apple Git-143)