zoukankan      html  css  js  c++  java
  • 更换github账号后,push被旧账号阻止

    和网上多数的教程不同,我是需要直接更换账号。切换后push一直被阻止。解决后记录下办法

    remote: Permission to new-name/practice.git denied to old-name.
    fatal: unable to access 'https://github.com/new-name/origin.git/': The requested URL returned error: 403

    错误码如上。

    https://help.github.com/articles/error-permission-to-user-repo-denied-to-user-other-repo/

    这是官方解释与解决办法,这说明push到了旧账号的库上了。如果你已经更改了ssh key但还是不行,那你可能和我犯了同样的错,没有把方式https换成ssh

    首先是key,我是直接重新生成了一个新key覆盖了之前的,不过看知乎,似乎可以直接更改github的ssh key.

    ssh-keygen -t rsa -C "youremail@xxx.com"

    还是和原始配置一样.ssh文件夹里打开id_rsa.pub,复制里面的key。回到github配置ssh key。然后验证

    $ ssh -T git@github.com

    然后是修改用户名和邮箱

    git config --global user.name "your_name"

    git config --global user.email "your_email"

    如果你和我之前一样,第一个账号是用https链接的,第二个账号也用https链接,就会被阻止,更改用户名和邮箱也不好使

    所以需要把链接方式https换成ssh

    git remote rm origin

    git remote add origin "Git仓库的ssh格式地址"----->这个在github上有

    此时再做git add    git commit   git push等操作就可以成功提交了

    注:如果你没有生成新key,是直接把原来的key绑定到新github账号上,那里可能需要登录旧账号删除它的ssh key

  • 相关阅读:
    BZOJ 3160 万径人踪灭
    BZOJ 2160 拉拉队排练
    模板 manacher算法
    [Tjoi2016&Heoi2016]求和
    [HZOI 2015]疯狂的机器人
    [BZOJ3456]城市规划
    BZOJ 4372 烁烁的游戏
    洛谷3794 签到题IV
    BZOJ 3730 震波
    BZOJ 4916 神犇和蒟蒻
  • 原文地址:https://www.cnblogs.com/liyan-web/p/5829268.html
Copyright © 2011-2022 走看看