如何在管理windows凭据管理器中使用git切换github帐户而不删除凭据?

如何在管理windows凭据管理器中使用git切换github帐户而不删除凭据?,git,github,Git,Github,每当我想将我的项目从一个帐户repo(源)添加到另一个帐户repo(目标)时,我一直在引用 所以我先做。当我尝试推入目标repo时(我已经从源文件夹中为目标创建了另一个文件夹,在推入之前我从目标repo中提取了内容),它会给我以下错误(正如我们在视频中看到的): 在拉取、配置user.name、user.email之后,仍然会给出该错误 所以我一直在遵循视频中的解决方案,但每次删除凭据并为这两个帐户再次添加凭据是很烦人的。我还尝试创建SSH密钥并将其添加到目标github帐户中。但这对我也不起作

每当我想将我的项目从一个帐户repo(源)添加到另一个帐户repo(目标)时,我一直在引用

所以我先做。当我尝试推入目标repo时(我已经从源文件夹中为目标创建了另一个文件夹,在推入之前我从目标repo中提取了内容),它会给我以下错误(正如我们在视频中看到的):

在拉取、配置user.name、user.email之后,仍然会给出该错误

所以我一直在遵循视频中的解决方案,但每次删除凭据并为这两个帐户再次添加凭据是很烦人的。我还尝试创建SSH密钥并将其添加到目标github帐户中。但这对我也不起作用


还有其他解决办法吗

如果Windows凭据管理器正在工作,
credential.helper
已设置为
manager
。要使用另一个帐户,您可以将该帐户添加到存储库URL或指定
credential.username
foo
是新帐户

git push https://foo@github.com/dest_userName/dest_Repo.git bar

如果您每次都需要键入或粘贴长URL,那么第一个就有点麻烦了。你可以为它添加一个新的遥控器

git remote add baz https://foo@github.com/dest_userName/dest_Repo.git
git push baz bar
您提到您已经创建并添加了SSH密钥,但它无法工作。这可能是因为您仍然使用HTTPS URL(
origin
,又名
https://github.com/dest_userName/dest_Repo.git/
)。相反,SSHURL是预期的,即
git@github.com:dest_userName/dest_Repo.git

git push git@github.com:dest_userName/dest_Repo.git bar


如果Windows凭据管理器正在工作,
credential.helper
已设置为
manager
。要使用另一个帐户,您可以将该帐户添加到存储库URL或指定
credential.username
foo
是新帐户

git push https://foo@github.com/dest_userName/dest_Repo.git bar

如果您每次都需要键入或粘贴长URL,那么第一个就有点麻烦了。你可以为它添加一个新的遥控器

git remote add baz https://foo@github.com/dest_userName/dest_Repo.git
git push baz bar
您提到您已经创建并添加了SSH密钥,但它无法工作。这可能是因为您仍然使用HTTPS URL(
origin
,又名
https://github.com/dest_userName/dest_Repo.git/
)。相反,SSHURL是预期的,即
git@github.com:dest_userName/dest_Repo.git

git push git@github.com:dest_userName/dest_Repo.git bar


非常感谢你。我在SSH-URL上使用了您的建议,并且它起了作用。再次感谢,你节省了很多时间。非常感谢。我在SSH-URL上使用了您的建议,并且它起了作用。再次感谢,你节省了很多时间。