如何以不同的用户名推送到 GitHub? [英] How do I push to GitHub under a different username?

查看:26
本文介绍了如何以不同的用户名推送到 GitHub?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个朋友和我正在共用我的电脑.我已经在 Windows 7 上使用 git bash shell 推送到 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

推荐答案

如果你使用不同的 windows 用户,你的 SSH 密钥和 git 设置将是独立的.

If you use different windows user, your SSH key and git settings will be independent.

如果这不适合您,那么您的朋友应该将您的 SSH 密钥添加到她的 Github 帐户中.

If this is not an option for you, then your friend should add your SSH key to her Github account.

虽然,以前的解决方案会让你像你自己一样推动,但它会让你进入她的回购.如果你不想要这个并且在同一台电脑上的不同文件夹中工作,你可以通过删除配置命令的 -g 标志在一个文件夹中本地设置用户名和电子邮件:

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

或者,如果你推送 https 协议,Github 每次都会提示输入用户名/密码(除非你使用密码管理器).

Alternatively, if you push over https protocol, Github will prompt for username/password every time (unless you use a password manager).

这篇关于如何以不同的用户名推送到 GitHub?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆