因此,我需要将我的个人 GitHub 帐户添加到我已经在使用我的工作 github 帐户的办公室笔记本电脑。所以我创建了一个单独的 ssh key 并将其存储到一个单独的文件中。我将新创建的 ssh 添加到我的个人 github 帐户中。
然后我添加了一个像这样的配置文件:
Work
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
Personal account
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_personal
然后,我在个人 git 存储库中创建了一个 PRIVATE 新存储库,并按如下方式克隆它,以便它将使用个人 ssh token :
git clone <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="67000e1327000e130f12054904080a4a170215140809060b" rel="noreferrer noopener nofollow">[email protected]</a>:prajatpadhi/udemy-react-maximillian.git
然后我做了一些提交并推送。但我很惊讶地发现提交的作者是我作品的用户 ID,因为我忘记更改本地存储库的用户名和电子邮件。
但在这种情况下不应该出现授权错误,因为存储库在个人 git hub 帐户中是私有(private)的。 GitHub 如何允许访问?
我的个人用户 ID 是 pp,工作的用户 ID 是 pp1。如何允许 pp1 将提交推送到 pp 的私有(private)存储库?
最佳答案
But shouldn't in such a case there should be an authorization error as the repository was private in the personal git hub account.
How did GitHub allowed access?
不,提交作者身份与身份验证/访问无关。
最好使用 conditional includeIf.<condition>.path
全局设置以便设置user.name
/user.email
取决于您所在的项目文件夹。
这样,您就不会忘记设置正确的名称/电子邮件,并且您创建的提交是由正确的作者完成的。
关于git - git 批准的凭据错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72941954/