最近使用git命令从github克隆仓库到版本,然后进行提交到github时报错如下:

[root@node1 git_test]# git push origin master
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/jsonhc/git_test.git/info/refs

fatal: HTTP request failed

解决办法:参考 http://sharadchhetri.com/2014/08/16/error-requested-url-returned-error-403-forbidden-accessing-github-repo/

这台本机没有配置与github的ssh密钥连接,直接通过的是httpds

1、确保不是git版本d低的问题

[root@wadeson wadeson]# git --version
git version 1.7.1

2、从github克隆仓库到本地:

git clone https://github.com/jsonhc/git_test.git

[root@wadeson wadeson]# git clone https://github.com/jsonhc/git_test.git
Initialized empty Git repository in /home/wadeson/git_test/.git/
remote: Counting objects: 20, done.
remote: Total 20 (delta 0), reused 0 (delta 0), pack-reused 20
Unpacking objects: 100% (20/20), done.

3、查看仓库内容,然后增加需要提交的文件

[root@wadeson git_test]# ll
总用量 20
-rw-r--r--. 1 root root 712 7月 31 23:59 flask_first.py
-rw-r--r--. 1 root root 2766 7月 31 23:59 landing.py
-rw-r--r--. 1 root root 1881 7月 31 23:59 menu_list.py
-rw-r--r--. 1 root root 10 7月 31 23:59 README.md
-rw-r--r--. 1 root root 377 7月 31 23:59 total.py

[root@wadeson git_test]# mv ../statistics_ip.py ./
[root@wadeson git_test]# ll
总用量 24
-rw-r--r--. 1 root root 712 7月 31 23:59 flask_first.py
-rw-r--r--. 1 root root 2766 7月 31 23:59 landing.py
-rw-r--r--. 1 root root 1881 7月 31 23:59 menu_list.py
-rw-r--r--. 1 root root 10 7月 31 23:59 README.md
-rw-r--r--. 1 root root 377 8月 3 15:01 statistics_ip.py

4、git config --global user.name "json_hc"

git config --global user.email "json_hc@163.com"

5、git remote set-url origin https://jsonhc@github.com/jsonhc/git_test.git

这条命令就是修改了.git/config下面的这条:

  url = https://jsonhc@github.com/jsonhc/git_test.git(原始url为url = https://github.com/jsonhc/git_test.git

6、git add statistics_ip.py

git commit -m "add statistics_ip.py to statistics ip of nginx"

[root@wadeson git_test]# git commit -m "add statistics_ip.py to statistics ip of nginx"
[master a460f0f] add statistics_ip.py to statistics ip of nginx
1 files changed, 22 insertions(+), 0 deletions(-)
create mode 100644 statistics_ip.py

7、git push -u origin master     第一次推送加上-u

[root@wadeson git_test]# git push -u origin master
Password:        这里需要提供github的密码
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 276 bytes, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://jsonhc@github.com/jsonhc/git_test.git
8e23043..a460f0f master -> master
Branch master set up to track remote branch master from origin.

然后进入github网站查看已岁推送的文件了

现在使用另外的主机进行开发的时候,首先第一步:

git pull远程仓库的文件

[root@node1 git_test]# git pull origin master
Password:
remote: Counting objects: 2, done.
remote: Total 2 (delta 1), reused 2 (delta 1), pack-reused 0
Unpacking objects: 100% (2/2), done.
From https://github.com/jsonhc/git_test
* branch master -> FETCH_HEAD
Updating 8e23043..a460f0f
Fast-forward
statistics_ip.py | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
create mode 100644 statistics_ip.py
[root@node1 git_test]# ll
total 24
-rw-r--r-- 1 root root 712 Aug 3 14:41 flask_first.py
-rw-r--r-- 1 root root 2766 Aug 3 14:41 landing.py
-rw-r--r-- 1 root root 1881 Aug 3 14:41 menu_list.py
-rw-r--r-- 1 root root 10 Aug 3 14:41 README.md
-rw-r--r-- 1 root root 377 Aug 3 15:24 statistics_ip.py
-rw-r--r-- 1 root root 377 Aug 3 14:41 total.py

这样才能保证不冲突,得到的是新的版本

下次再次从本地提交就不需要执行以上部分操作:

[root@node1 wadeson]# cd git_test/
[root@node1 git_test]# ll
total 28
-rw-r--r-- 1 root root 712 Aug 3 14:41 flask_first.py
-rw-r--r-- 1 root root 2766 Aug 3 14:41 landing.py
-rw-r--r-- 1 root root 1881 Aug 3 14:41 menu_list.py
-rw-r--r-- 1 root root 10 Aug 3 14:41 README.md
-rw-r--r-- 1 root root 377 Aug 3 15:24 statistics_ip.py
-rw-r--r-- 1 root root 739 Aug 3 15:58 statistics_nginx_ip_flow.py
-rw-r--r-- 1 root root 377 Aug 3 14:41 total.py
[root@node1 git_test]# git add statistics_nginx_ip_flow.py
[root@node1 git_test]# git commit -m "in additional ip and flow of nginx"
[master 6d15afd] in additional ip and flow of nginx
1 files changed, 34 insertions(+), 0 deletions(-)
create mode 100644 statistics_nginx_ip_flow.py
[root@node1 git_test]# git push origin master
Password:
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 637 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://jsonhc@github.com/jsonhc/git_test.git
a460f0f..6d15afd master -> master

注意:

(gnome-ssh-askpass:24029): Gtk-WARNING **: cannot open display:

帮助
1
unset SSH_ASKPASS

  

 从一个远程的github只有一个README.md的新项目,将本地数据进行提交的具体步骤:
1、将远程项目克隆到本地
  git clone https://github.com/jsonhc/tools.git
2、git config --global user.name "json_hc"
 git config --global user.email "json_hc@163.com"
3、修改提交的https的url
  git remote set-url origin https://jsonhc@github.com/jsonhc/tools.git
4、添加需要提交的数据
  git add init.sh
5、进行提交
  git commit -m "init shell script"
6、

[root@xen tools]# git push -u origin master
Password:        输入密码

Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 653 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://jsonhc@github.com/jsonhc/tools.git
f431558..59cbb6a master -> master
Branch master set up to track remote branch master from origin.

git推送到github报错:error: The requested URL returned error: 403 Forbidden while accessing https://github.com的更多相关文章

  1. GitHub 在使用命令行 git push 时报错:The requested URL returned error: 403

    使用 git 的命令行向 GitHub 提交的时候,报错: [Young@localhost OtherLang]$ git push origin master error: The request ...

  2. 解决git提交问题error: The requested URL returned error: 403 Forbidden while accessing

    git提交代码时,出现这个错误"error: The requested URL returned error: 403 Forbidden while accessing https&qu ...

  3. git clone出现的error: The requested URL returned error: 401 Unauthorized

    error: The requested URL returned error: 401 Unauthorized while accessing https://git.oschina.net/.. ...

  4. error: The requested URL returned error: 401 Unauthorized while accessing

    我遇到的其中一个问题. 问题描述: 在git push -u origin master是,提示“error: The requested URL returned error: 401 Unauth ...

  5. 解决git clone时报错:The requested URL returned error: 401 Unauthorized while accessing

    版本问题,最直接的解决办法就是重新编辑安装git吧: 1. 下载:# wget -O git.zip https://github.com/git/git/archive/master.zip 2. ...

  6. 解决github push错误The requested URL returned error: 403 Forbidden while accessing

    来源:http://blog.csdn.net/happyteafriends/article/details/11554043 github push错误: git push error: The  ...

  7. git push The requested URL returned error: 403 Forbidden while accessing

    错误提示信息: error: The requested URL returned error: Forbidden while accessing https://github.com/xingfu ...

  8. 解决github push错误The requested URL returned error: 403 Forbidden while accessing(转)

    github push错误: git push error: The requested URL returned error: 403 Forbidden while accessing https ...

  9. git推送代码Gogs报401错误

    1.git push 报错:RPC failed; HTTP 401 curl 22 The requested URL returned error: 401 The remote end hung ...

随机推荐

  1. linux的/etc/hosts的作用

    转自:http://blog.chinaunix.net/uid-28559065-id-4145820.html  linux /etc/hosts文件作用   分类: LINUX linux /e ...

  2. pageResponse - 让H5适配移动设备全家

    http://www.cnblogs.com/PeunZhang/p/4517864.html

  3. Vscode 调试 C 语言时数组值无法显示的问题

    使用 Vscode 的 Gdb 扩展调试 C 语言时,发现数组变量在 变量列表里面中显示为指针,且只显示为其第一个元素的值,无法看到所有元素的值. 如图所示: 解决: 假设有一个元素个数为10的数组v ...

  4. 文艺青年装B指南

        和大龄文艺青年们去凤凰的时候,很难不注意到狭窄小道旁边的文艺小店.有提供焦糖玛奇朵的咖啡店,有兜售梦露赫本明信片和烟雨 凤凰笔记本的店铺,还有复古式的静吧,常驻唱民谣小众歌曲的流浪歌手.我每看 ...

  5. 运用JS设置cookie、读取cookie、删除cookiev

    JS设置cookie: 假设在A页面中要保存变量username的值("jack")到cookie中,key值为name,则相应的JS代码为: document.cookie=&q ...

  6. 2017 Multi-University Training Contest - Team 3——HDU6063 RXD and math

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6063 题目意思:字面意思,给出n,k,算出这个式子的答案. 思路:比赛的时候是打表找规律过了,赛后仔细 ...

  7. 用Nginx反向代理Node.js

    安装pm2 npm install pm2 -g ln -s /home/download/node-v8.11.1-linux-x64/lib/node_modules/pm2/bin/pm2 /u ...

  8. CGI/FastCGI/mod_php工作原理

    先了解一下普通cgi的工作流程:web server收到用户请求,并把请求提交给cgi程序,cgi程序根据请求提交的参数作相应处理,然后输出标准的html语句返回给web server,web ser ...

  9. vue中获取客户端IP地址(不需要额外引入三方文件)

    之前看了几种方法 ,都是引入腾讯,新浪,搜狐等的三方js文件来查询IP地址,但是我自己测试的时候IP地址不准确,所以就找了找,发现了这个方法,准确的获取到了IP地址和cmd的ipconfig获取到的I ...

  10. python中读取json文件报错,TypeError:the Json object must be str, bytes or bytearray,not ‘TextIOWrapper’

    利用python中的json读取json文件时,因为错误使用了相应的方法导致报错:TypeError:the Json object must be str, bytes or bytearray,n ...