我想咨詢社區我應該如何設定我的終端,以便在推送到 repro 時自動使用正確的身份檔案。
目前,我正在嘗試使用 ssh 組態檔:
~/ssh/配置
# First account
Host github.com:my_first_github_account
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_user1
# Second account
Host github.com:my_second_github_account
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_user2
我將任何 git 用戶特定的端點映射到它的身份檔案,并且在授權自己時它是這樣作業的:
> ssh [email protected]:my_first_github_account
Hi my_first_github_account! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
> ssh [email protected]:my_second_github_account
Hi my_second_github_account! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
我當前的問題是,當推git送到遠程源(當然是授權這樣做)時,它使用了錯誤的身份檔案,而不是應該考慮的身份檔案:
> git config --get remote.origin.url
[email protected]:my_first_github_account/my-repo.git
> 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.
uj5u.com熱心網友回復:
該:account_name部分不應是Host您的.ssh/config.
顯然,命令列 ssh 可以使用包含:(我不知道)的主機名,但會git提取該github.com部分并運行 ssh 命令來嘗試ssh github.com- 并且您.ssh/config不包含任何github.com單獨的配置。
修復很簡單:
更改您的Host值,例如更改為Host github.workand Host github.perso,并使用:
git clone github.work:username/repo
git clone github.perso:username/repo
為了完整起見:您可以使用您定義的主機名,只需使用較長的 url 語法來定位您的 github 存盤庫:
git clone ssh://github.com:username/username/repo.git
但是選擇與短 url 形式一起使用的主機名更方便。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/488189.html
上一篇:Gitpullerrorclient_loop:senddisconnect:ConnectionresetbypeeriB/s
