部署的gitlab,采用ssh方式连接gitlab,在客户机上产生公钥上传到gitlab的SSH-Keys里,git clone下载和git push上传都没问题,这种方式很安全。
后来应开发同事要求采用http方式连接gitlab,那么首先将project工程的“Visibility Level”改为“Public”公开模式,要保证gitlab的http端口已对客户机开放。
后面发现了一个问题:
http方式连接gitlab后,git clone下载没有问题,但是git push上传有报错:
error: The requested URL returned error: 401 Unauthorized while accessing http://git.xqshijie.net:8081/weixin/weixin.git/info/refs
fatal: HTTP request failed
或者
The requested URL returned error: 403 Forbidden while accessing
解决办法:
修改代码里的.git/config文件
[root@test-huanqiu weixin]# cd .git
[root@test-huanqiu .git]# cat config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = http://git.wangshibo.net:8081/weixin/weixin.git
[branch "master"]
remote = origin
merge = refs/heads/master
修改如下:
[root@test-huanqiu .git]# cat config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = http://wangshibo:HU@wew12378!h8@git.wangshibo.net:8081/weixin/weixin.git
[branch "master"]
remote = origin
merge = refs/heads/master
网友评论