Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git账号切换,提交代码被拒绝的问题 #144

Open
ahua52 opened this issue Oct 17, 2016 · 2 comments
Open

git账号切换,提交代码被拒绝的问题 #144

ahua52 opened this issue Oct 17, 2016 · 2 comments

Comments

@ahua52
Copy link

ahua52 commented Oct 17, 2016

场景问题

今天把家里的电脑拿来用,我自己在这台电脑上提交代码,报Permission denied的错误

问题解决步骤

1.设置Git的user name和email

git config --global user.name "yourname"
git config --global user.email "youremail"

2.生成SSH密钥

查看是否已经有了ssh密钥:cd ~/.ssh
如果没有密钥则不会有此文件夹,有则备份删除
生存密钥:
ssh-keygen -t rsa -C “haiyan.xu.vip@gmail.com”
按3个回车,密码为空。
Your identification has been saved in /home/tekkub/.ssh/id_rsa.
Your public key has been saved in /home/tekkub/.ssh/id_rsa.pub.
The key fingerprint is:
………………
最后得到了两个文件:id_rsaid_rsa.pub
添加密钥到ssh:ssh-add 文件名,需要之前输入密码.

在github上添加ssh密钥,这要添加的是“id_rsa.pub”里面的公钥。
打开https://github.com/,在设置中添加密钥

到这,问题还没解决 git push 还是 还是报拒绝的错误

3.查看账号信息

git config --list 返回的信息也是正确的

4.验证权限

ssh -T git@githun.com
返回的信息是
Hi lut! You've successfully authenticated, but GitHub does not provide shell access.

5.再一次 设置远程路径

git remote set-url origin git@github.com:tinper-bee/formControl.git
然后再git push 我的代码 上github上看发现还是原来的账号提交的代码(因之前下载下来的代码是用之前的账号)
我在本地代码再做一次修改 然后提交 这次github上的账号显示正常

@donething
Copy link

感谢,执行第5步后,push成功 : )

@lusson-luo
Copy link

执行第5步成功,我的错误是,之前用 https 的 remote,不成功,换 ssh 的remote 成功

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants