.gitconfig:
[user]
name = Dr.jacky
email = personal.email@gmail.com
signingKey = ""
[includeIf "gitdir:/Users/drjacky/Projects/CompanyName/"]
path = /Users/drjacky/gitconfigcompanyname/.gitconfig
[core]
excludesfile = /Users/drjacky/.gitignore_global
autocrlf = input
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[commit]
template = /Users/drjacky/.stCommitMsg
gpgSign = false
[gpg]
program = gpg
[tag]
forceSignAnnotated = false
gitconfigcompanyname/.gitconfig:
[user]
name = My Name
email = my.company.email@company.com
.ssh/config:
# --- Sourcetree Generated ---
Host Personal-GitHub
HostName github.com
User Drjacky
PreferredAuthentications publickey
# IdentityFile /Users/drjacky/.ssh/Personal-GitHub
IdentityFile ~/.ssh/id_rsa
UseKeychain yes
AddKeysToAgent yes
# ----------------------------
# Company Work GitHub
Host github.com/Company
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_companyname
UseKeychain yes
AddKeysToAgent yes
我已经通过 ssh-add
命令添加了第二个 SSH 公钥。
现在,在终端/iTerm2 中,我切换到路径 /Users/drjacky/Projects/CompanyName/HERE
,然后运行以下命令:git clone httpUrlOfMyCompanyRepo
或者 git clone sshOfMyCompanyRepo
;不管用哪个命令,都无法访问:
远程:未找到仓库。 致命错误:'https://github.com/CompanyName/reponame.git/' 仓库未找到
当我在 CompanyName 文件夹路径下运行 git config user.email
命令时,它显示的是我的个人电子邮件地址。
当我运行 git config --list
命令时:
credential.helper=osxkeychain
user.name=Dr.jacky
user.email=personal.email@gmail.com
user.signingkey=
includeif.gitdir:/Users/drjacky/Projectz/CompanyName/.path=/Users/drjacky/gitconfigcompanyname/.gitconfig
core.excludesfile=/Users/drjacky/.gitignore_global
core.autocrlf=input
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
commit.template=/Users/drjacky/.stCommitMsg
commit.gpgsign=false
gpg.program=gpg
tag.forcesignannotated=false
(END)
git bugreport
:
[System Info]
git version:
git version 2.28.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Darwin 19.6.0 Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64 x86_64
compiler info: clang: 11.0.3 (clang-1103.0.32.62)
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/zsh
注释:
- 我已经卸载了SourceTree但没有帮助。
- git版本号为2.28.0。
- 使用工具成功克隆存储库后,正确地运行没有问题。
更新: 我检查了Github仪表板上的SSH部分,它显示SSH密钥根本没有被使用!
ssh-add
并提供私钥才能使用git访问我们的存储库。 - eftshift0ssh-add -l
时,它显示了带有电子邮件的两个密钥。 - Dr.jacky