公众号

git总结

Git 403问题总结:

1.

1
2
3
4
5
$ Git push origin :dev-xx
remote: Permission to xxx/xxx.git denied to xxx.
fatal: unable to access 'https://github.com/xxx/xxx.git/': The requested URL returned error: 403

问题原因主要是电脑上有两个github账号时,每个账号对应不同的ssh,比如:

1
2
3
4
5
6
7
he:.ssh he$ ls
config id_rsa.pubid_rsa_he.pub
id_rsa id_rsa_heknown_hosts
he:.ssh he$ cat config
  1. Default GitHub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
Host github-he
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_he

这时需要切换成对应的ssh

1
2
$ git remote rm origin
$ git remote add origin git@github-he:xxx/xxx.git

然后再执行上次的命令,就会成功了,如下:

1
2
3
$ git push origin :dev-xxx
To git@github-he:xxx/xxx.git
- [deleted] dev-xxx

最后想说:Fork me on GitHub 欢迎 Star

  • 本文作者:Hunter-Zack
  • 本文链接: 2017/09/git+403/
  • 版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 CN 许可协议。转载请注明出处!
🙈坚持原创技术分享,您的支持将鼓励我继续创作🙈