簡體   English   中英

如何在其他注冊用戶下克隆git private repo?

[英]How to clone a git private repo under a different registered user?

我有一個已經使用多年的GitHub句柄,但是,在加入一家新公司之后,他們要求我在公司電子郵件地址下注冊一個新的GitHub帳戶。 現在,我無法克隆私有存儲庫,因為將user.name設置為我的常規GitHub句柄。

在此頁面上閱讀可以在git clone https://usernamenew@github.com/companyname/repo-name.git類的URL之前添加用戶名。

但是,我得到了錯誤

Cloning into 'repo-name'...
remote: Repository not found.
fatal: repository 'https://usernamenew@github.com/companyname/repo-name.git/' not found

如何使用其他用戶名克隆公司的倉庫?

根據示例輸出,git不會要求您輸入密碼。 看起來像:

  • 您的憑據已緩存
  • 憑據用於您的個人帳戶,而不是您的新公司帳戶

您已將新用戶名正確添加到URL。 但是默認情況下,git僅在應用緩存的憑據時才關心主機。

您可以使用useHttpPath的選項gitcredentials通知Git考慮URL路徑,以及。 這將允許您使用具有不同存儲庫的不同帳戶。

https://git-scm.com/docs/gitcredentials.html#Documentation/gitcredentials.txt-useHttpPath

useHttpPath

默認情況下,Git認為HTTP URL的“路徑”組件不值得通過外部幫助器進行匹配。 這意味着為https://example.com/foo.git存儲的憑據也將用於https://example.com/bar.git 如果確實要區分這些情況,請將此選項設置為true。

通過運行以下命令進行配置:

git config --global credential.https://github.com.useHttpPath true

config user.name與身份驗證無關。

請檢查您的git config credential.helper設置。
如果設置,則意味着您的憑據可能已被緩存:您將需要刪除它們,或者最好使用SSH URL(可以在其中為不同的URL設置不同的私鑰 )。

如果這不是緩存問題,只需檢查usernamenew確實具有對github.com/companyname/repo-name.git訪問github.com/companyname/repo-name.git

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM