zoukankan      html  css  js  c++  java
  • Git 报错:The requested URL returned error: 403

    执行报错:

    [root@localhost learngit_2]# git remote add origin https://github.com/shengleqi/gitskills.git
    [root@localhost learngit_2]# git push -u origin master
    error: The requested URL returned error: 403 Forbidden while accessing https://github.com/shengleqi/gitskills.git/info/refs
    
    fatal: HTTP request failed

    修复方式:

    可以看到上面红色加粗的文字(The requested URL returned error: 401 Authorization Required),是权限问题导致的,可以修改.git/config文件追加用户名和密码:

    1)编辑.git/config文件

    2)在[remote “origin”]下找到找到url变量

    3)修改url = https://github.com/user/test.git,修改为url = ssh://git@github.com/user/test.git,修改完了保存

    4)通过git push origin master进行同步,已经可以成功了

    修改如下:

    [root@localhost learngit_2]# cat .git/config
    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
    [remote "origin"]
        url =  ssh://git@github.com/shengleqi/gitskills.git
        fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
        remote = origin
        merge = refs/heads/master

    执行成功:

    [root@localhost learngit_2]# git push -u origin master
    The authenticity of host 'github.com (192.30.255.112)' can't be established.
    RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'github.com,192.30.255.112' (RSA) to the list of known hosts.
    Counting objects: 26, done.
    Compressing objects: 100% (19/19), done.
    Writing objects: 100% (26/26), 2.08 KiB, done.
    Total 26 (delta 6), reused 0 (delta 0)
    remote: Resolving deltas: 100% (6/6), done.
    To ssh://git@github.com/shengleqi/gitskills.git
     * [new branch]      master -> master
    Branch master set up to track remote branch master from origin.
  • 相关阅读:
    PHP 操作MySQL时mysql_connect( )和Mysqli( )的两种报错机制
    OS + macOS Mojave 10.14.4 / sushi / ssh-keygen / ssh-copy-id
    script ajax / XHR / XMLHttpRequest
    java socket / No buffer space available
    OS + Ubuntu ARM Android
    mysql中批量替换数据库中的内容的sql
    linux下ubuntu系统安装及开发环境配置
    PHP 截取字符串专题
    在Ubuntu中用root帐号登录
    理解javascript的caller,callee,call,apply概念
  • 原文地址:https://www.cnblogs.com/sheng-247/p/7515842.html
Copyright © 2011-2022 走看看