【发布时间】:2021-12-07 05:42:54
【问题描述】:
昨天我创建了一个 ssh 密钥并克隆了一个 repo 以供工作。进行一些更改后,我尝试推送提交:
git push
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I have read this active SO post。我的问题仍然存在。我不知道如何追查这个问题,所以会分享我认为相关的所有内容。
在我的笔记本电脑上,我有个人和工作回购。我的工作工作存在于嵌套在~/Documents/Projects/Zen/Projects/ 下的任何目录中。其他任何地方,例如~/Documents/Projects/Personal/是个人github。
我的 .gitconfig 看起来像这样:
[user]
email = 12345+doug@users.noreply.github.com
name = 12345doug
[includeIf "gitdir:/home/doug/Documents/Projects/Zen/"]
path = ~/.git-zen
/.git-zen 看起来像这样:
[user]
email = doug@work.com
name = doug-work
目前我在一个仓库中:
pwd
/home/doug/Documents/Projects/Zen/Projects/analytics-psql-action
准备好提交一些提交:
~/Documents/Projects/Zen/Projects/analytics-psql-action$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
我在这个目录中的 git 配置似乎是正确的:
git config user.name
doug-work
和
git config user.email
doug@work.com
为了创建我的 ssh 密钥,我在 github.com 上关注了this post。
ssh-keygen -t rsa -b 4096 -C "doug@work.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
然后我将每个 this tutorial 的密钥添加到我的工作 github 设置中。
到目前为止,我认为我已经按照应有的方式进行了所有设置?但是当我尝试从这个 repo 中推送时:
~/Documents/Projects/Zen/Projects/analytics-psql-action$ git push
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
无奈之下,我重命名了 repo 并尝试从新克隆:
git clone git@github.com:work/analytics-psql-action.git # real path actually used not 'work'
Cloning into 'analytics-psql-action'...
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
在 repo 本身上,如果我进入 repo settings > manage access 我可以看到自己,doug-work 具有管理员访问权限。
如何克隆并推送到 repo?我应该从哪里开始尝试找出为什么我的 ssh 密钥设置不起作用?
【问题讨论】:
-
我也有同样的问题;
ERROR: Repository not found.被触发,因为存储库是私有的。我不知道为什么在这里使用备用 SSH 身份会导致问题,或者如何解决它。 -
查看stackoverflow.com/a/61150726/266747;有一些策略可以将
user.email与给定的 ssh IdentityFile 相关联。我还建议在~/.ssh/config中为给定的Host条目添加IdentitiesOnly=yes,这将防止ssh 尝试其他身份。