昨天我创建了一个SSH密钥并克隆了一个与工作相关的仓库。在做了一些更改后,我尝试推送提交:
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.
我已经阅读了这篇活跃的SO帖子。我的问题仍然存在。我不知道如何追踪问题,因此会分享我认为相关的所有内容。
在我的笔记本电脑上,我有个人和工作存储库。我的工作存储库位于~/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上的这篇文章进行操作。
ssh-keygen -t rsa -b 4096 -C "doug@work.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
我随后根据此教程的指导,在我的工作github设置中添加了密钥。
目前为止,我认为我已经按照要求设置好了一切?但是当我尝试从这个仓库内推送时:
~/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.
我绝望地将仓库重命名,并尝试从头克隆:
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
在仓库本身上,如果我进入仓库设置 > 管理访问权限,我可以看到自己,doug-work拥有管理员访问权限。
我如何克隆并推送到仓库?我应该从哪里开始查找为什么我的ssh密钥设置不起作用?
user.email
与给定的 ssh IdentityFile 关联的策略。我还建议在~/.ssh/config
中为给定的Host
条目添加IdentitiesOnly=yes
,这将防止 ssh 尝试其他身份验证。 - Barton Chittenden