LEN

解决 git version 1.7.1 403 Forbidden while accessing
今天过节没意思,在家想研究下swoole, github 中又起了project 开发环境为Centos6.5[r...
扫描右侧二维码阅读全文
11
2017/02

解决 git version 1.7.1 403 Forbidden while accessing

今天过节没意思,在家想研究下swoole, github 中又起了project

开发环境为Centos6.5

[root@bf tcp_message]#cd test
[root@bf test]#git clone https://github.com/libenfu/tcp_message.git
Initialized empty Git repository in /data/tcp_message/test/tcp_message/.git/
warning: You appear to have cloned an empty repository.

[root@bf test]#ll -a
total 12
drwxr-xr-x 3 root root 4096 Feb 11 18:56 .
drwxr-xr-x 3 root root 4096 Feb 11 18:56 ..
drwxr-xr-x 3 root root 4096 Feb 11 18:56 tcp_message

[root@bf test]#cd tcp_message/
[root@bf tcp_message]#echo "# tcp_message" > .README.md
[root@bf tcp_message]#ll -a
total 16
drwxr-xr-x 3 root root 4096 Feb 11 18:58 .
drwxr-xr-x 3 root root 4096 Feb 11 18:56 ..
drwxr-xr-x 7 root root 4096 Feb 11 18:56 .git
-rw-r--r-- 1 root root   14 Feb 11 18:58 .README.md

[root@bf tcp_message]#git commit -m 'first commit'
[master (root-commit) 994b0c5] first commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 .README.md

[root@bf tcp_message]#git remote add origin https://github.com/libenfu/tcp_message.git
fatal: remote origin already exists.
[root@bf tcp_message]#git push -u origin master
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/libenfu/tcp_message.git/info/refs

fatal: HTTP request failed

执行到上一步开始报403 , 我服务器并没有设置git 账号所以需要设置 vim .git/config文件
修改:

[remote "origin"]  
    url = https://github.com/benfu/example.git  

改为:

[remote "origin"]  
    url = https://benfu@github.com/benfu/example.git  

实际就是url前带用户账号请求, 每次提交都需要输入密码

[root@bf tcp_message]#git version
git version 1.7.1
You have new mail in /var/spool/mail/root
[root@bf tcp_message]#vim .git/config 
[root@bf tcp_message]#git push -u origin master
Password: 
Counting objects: 3, done.
Writing objects: 100% (3/3), 218 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://libenfu@github.com/libenfu/tcp_message.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
[root@bf tcp_message]#git log
commit 994b0c59d7ea8680779e6150ab625a90e2c20779
Author: benfu <lbf2131@163.com>
Date:   Sat Feb 11 18:59:34 2017 +0800

就这样提交成功了 简单记录下, 元宵节又吃撑了, 有妈在身边就是好呀 ^v^!

Last modification:February 11th, 2017 at 07:20 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment