使用http作为不同的github帐户

时间:2021-05-29 23:06:43

I'm trying to connect using http for a second github account I've recently set up. When I pushed to https://github.com/usernameOf2ndGithubAccount/repo.git, I always got the following error:

我正在尝试使用http连接我最近设置的第二个github帐户。当我推送到https://github.com/usernameOf2ndGithubAccount/repo.git时,我总是遇到以下错误:

remote: Permission to usernameOf2ndGithubAccount/repo.git denied to usernameOf1stGithubAccount

remote:usernameOf2ndGithubAccount / repo.git对usernameOf1stGithubAccount的权限被拒绝

That means I've probably made the username of my 1st github account as the default somewhere. But I've looked through all my environment variables and bashrc but couldn't find it to be set anywhere. Can someone please point out how to fix this issue? Thanks!

这意味着我可能已将我的第一个github帐户的用户名作为默认位置。但我查看了所有环境变量和bashrc,但无法在任何地方找到它。有人可以指出如何解决这个问题吗?谢谢!

P.S. I've tried connecting using ssh for my 2nd github account (by using a new pair of private/public key), and that works fine.

附:我已经尝试使用ssh连接我的第二个github帐户(通过使用一对新的私钥/公钥),并且工作正常。

2 个解决方案

#1


0  

You can specify the username to use in the URL, e.g.: https://usernameOf2ndGithubAccount@github.com/usernameOf2ndGithubAccount/repo.git

您可以指定要在URL中使用的用户名,例如:https://usernameOf2ndGithubAccount@github.com/usernameOf2ndGithubAccount/repo.git

#2


0  

When you set-up git, it will ask for a username and email. This will we global for all your repositories.

当你设置git时,它会要求输入用户名和电子邮件。这将是我们所有存储库的全局。

You could see your name and email with (which could be different for each repository)

您可以看到您的姓名和电子邮件(每个存储库可能有所不同)

git config user.name
git config user.email

You could change it as follows (only for the current git repository)

您可以按如下方式更改它(仅适用于当前的git存储库)

git config user.name "myname"
git config user.email "my@email.com"

To see your/update global config, pass --global (after config), e.g.

要查看/更新全局配置,请传递--global(在配置之后),例如

git config --global user.email

When using TortioseGit, you could easily view and change with a GUI.

使用TortioseGit时,您可以使用GUI轻松查看和更改。

使用http作为不同的github帐户

#1


0  

You can specify the username to use in the URL, e.g.: https://usernameOf2ndGithubAccount@github.com/usernameOf2ndGithubAccount/repo.git

您可以指定要在URL中使用的用户名,例如:https://usernameOf2ndGithubAccount@github.com/usernameOf2ndGithubAccount/repo.git

#2


0  

When you set-up git, it will ask for a username and email. This will we global for all your repositories.

当你设置git时,它会要求输入用户名和电子邮件。这将是我们所有存储库的全局。

You could see your name and email with (which could be different for each repository)

您可以看到您的姓名和电子邮件(每个存储库可能有所不同)

git config user.name
git config user.email

You could change it as follows (only for the current git repository)

您可以按如下方式更改它(仅适用于当前的git存储库)

git config user.name "myname"
git config user.email "my@email.com"

To see your/update global config, pass --global (after config), e.g.

要查看/更新全局配置,请传递--global(在配置之后),例如

git config --global user.email

When using TortioseGit, you could easily view and change with a GUI.

使用TortioseGit时,您可以使用GUI轻松查看和更改。

使用http作为不同的github帐户