我如何使用不同的用户名推送到GitHub? [英] How do I push to GitHub under a different username?
问题描述
pre $ git push her_github_repository our_branch
错误:her_username / repository.git的权限被拒绝给my_username。
fatal:远程终端意外挂起
如果你使用不同的Windows用户,你的SSH密钥和git设置将是独立的。
虽然如果这不适合你,那么你的朋友应该添加你的SSH密钥到她的github账户。
虽然以前的解决方案会让你保持自己的地位,但它可以让你推进她的回购。如果你不想要这个,并在同一台PC上的不同文件夹中工作,你可以通过删除 -g
配置标志在git文件夹中的本地设置用户名和电子邮件命令:
git config user.name her_username
git config user.email her_email
编辑哦,我没有先考虑它,但是如果你推过 https
协议,我想github每次都会提示输入用户名/密码(除非你使用密码管理器)。所以这也可能是一个解决方案。
A friend and myself are sharing my computer. I've made pushes to GitHub using the git bash shell on Windows 7. Now we're in a different project on that computer and I need her to push to her account. But it keeps trying to use my username and saying I don't have access to her repository:
$ git push her_github_repository our_branch
ERROR: Permission to her_username/repository.git denied to my_username.
fatal: The remote end hung up unexpectedly
if you use different windows user, your SSH key and git settings will be independent.
Although, if this is not an option for you, then your friend should add your SSH key to her github account.
Although, previous solution will keep you pushing as yourself, but it will allow you to push into her repo. If you don't want this and work in different folder on the same pc, you can setup username and email locally inside a folder with git by removing -g
flag of the config command:
git config user.name her_username
git config user.email her_email
edit Oh and, I didn't think about it first, but if you push over https
protocol, I think github prompt for username/password every time (unless you use a password manager). So this could also be a solution.
这篇关于我如何使用不同的用户名推送到GitHub?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!