我能夠在沒有任何錯誤的情況下對 repo 進行 Git 克隆。但是,當我嘗試在 GitHub 上向上游推送任何分支時,我收到以下錯誤:
(base) guoling@Guo-MacBook-Pro test % git push --set-upstream origin test-branch
ERROR: Permission to guoling9419/test.git denied to myGitHubUsername.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我該如何解決上述問題?
這myGitHubUsername是我的 GitHub 用戶名。
我在筆記本電腦上設定了 ssh 公鑰私鑰對。并且,已經將我的 ssh 公鑰 ( id_rsa.pub) 添加到 GitHub 頁面。
我在用macOS Monterey version 12.4.
我不小心覆寫了我的~/.ssh/config檔案。我試圖通過執行以下操作來解決它~/.ssh/config:
Host agent1
User root
HostName 198.199.92.88
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
我正在關注這個專門的 GitHub 頁面和這個 Stackoverflow 帖子進行除錯。
當我這樣做時ssh -T [email protected],我得到了輸出Hi myGitHubUsername! You've successfully authenticated, but GitHub does not provide shell access.
當我這樣做時ssh github,我得到了輸出ssh: Could not resolve hostname github: nodename nor servname provided, or not known
當我這樣做時eval "$(ssh-agent -s)",我得到了輸出Agent pid 50031。
當我這樣做時ssh-add -l -E sha256,我得到了輸出The agent has no identities.
當我這樣做時ssh-add -l -E md5,我得到了輸出The agent has no identities.
uj5u.com熱心網友回復:
這里的主要問題是用戶myGitHubUsername沒有訪問存盤庫的權限guoling9419/test.git。你用 ssh 做的任何事情都不會改變這個事實,盡管你用 ssh 做的事情可以改變 GitHub認為你是誰。
當我這樣做時
ssh -T [email protected],我得到了輸出Hi myGitHubUsername! You've successfully authenticated, but GitHub does not provide shell access.
假設myGitHubUsername是正確的名稱,你已經在你的 mac 上設定好了。您只需要myGitHubUsername授予訪問guoling9419/test.gitGitHub 上存盤庫的權限(可能是通過 GitHub Web 界面,或者可能通過他們的ghcli),或者更改 URL 以指向您應該使用的任何存盤庫而guoling9419/test.git不是.git remote set-url origin new-url
其余部分是可選閱讀
我正在使用
macOS Monterey version 12.4.當我做
eval "$(ssh-agent -s)"...
不要在 macOS 上這樣做:現代 macOS 在您登錄筆記本電腦(或任何硬體)時為您設定了一個用戶代理,因此已經提供了一個。
(像這樣開始一個新的在技術上沒有害處,但這會禁用一些有用的功能。)
當我做
ssh-add -l...
請注意,-l僅列出當前添加的身份。如果您需要添加一些身份,請使用ssh-add without -l . 有關詳細資訊,請參閱檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/497149.html
上一篇:我已經在GitHub上部署了我的TailwindCSS專案,但它突然停止了頁面部署
下一篇:git無法推送到現有的倉庫
