【发布时间】:2020-11-28 02:33:21
【问题描述】:
.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 pub。
现在,在终端/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
- 使用工具成功克隆 repo 后,它可以正常工作,没有问题。
更新: 我检查了 Github 仪表板上的 SSH 部分,它显示 SSH 密钥根本没有被使用!
【问题讨论】:
-
您设置了访问该存储库的凭据,对吧?
-
@eftshift0 是的,我在 GitKraken(以及之前在 SourceTree 上)上使用相同的 RSA 密钥来克隆存储库。他们正确地使用了这些工具。
-
好的....但是您是否设置了它们以便 git 可以使用它们?就我而言,我需要运行
ssh-add提供私钥才能使用 git 访问我们的存储库。 -
@eftshift0 是的,正如我在问题中提到的那样,我已经添加了它们。我跟着这个:stackoverflow.com/a/3486339/421467。当我运行
ssh-add -l时,它会显示电子邮件的两个键。 -
@eftshift0 请查看更新后的问题。钥匙根本没用过!但是,我之前加过。现在,我创建了一个新的 pub/private 密钥并使用了它们,但问题仍然存在。
标签: git github ssh-keys git-config