git push upload code to Gitlab, error 401 or 403

Source: Internet
Author: User

Previously deployed Gitlab code hosting platform, the use of SSH connection Gitlab, on the client to generate a public key uploaded to Gitlab Ssh-keys, the git clone download and git push upload is no problem, this way is safe.

Later, you should develop a colleague to request an HTTP connection to Gitlab, then first change the project project's "Visibility level" to "public" open mode, and make sure that the Gitlab HTTP port is open like a client.

A problem was found later:
HTTP connection gitlab, git clone download no problem, but git push upload error:
Error:the requested URL returned error:401 unauthorized while accessing http://git.xqshijie.net:8081/weixin/weixin.git /info/refs
Fatal:http request failed

Or
The requested URL returned error:403 Forbidden while accessing

Examples are as follows:
Suppose git has a URL of http://git.wangshibo.net
[Email protected] ~]# Mkdir/root/git
[Email protected] ~]# Cd/root/git
[[email protected] git]# git init.
[[email protected] git]# git clone http://git.wangshibo.net:8081/weixin/weixin.git
Initialized Empty Git repository in/root/git/weixin/.git/
Remote:counting Objects:10, done.
Remote:compressing objects:100% (6/6), done.
Remote:total (Delta 0), reused 0 (Delta 0)
Unpacking objects:100% (10/10), done.

above you can see that the git clone code
[[email protected] git]# ll
Total 4
Drwxr-xr-x. 3 root root 4096 Nov 15:58 weixin
[[email protected] git]# cd weixin/
[[email protected] weixin]# LL
total 8
-rw-r--r--. 1 root root (15:58 heihei
-rw-r--r--. 1 root root 1 Nov 15:38 readme.md

Now test the GIT push
[[email protected] weixin]# git rm heihei
[[Email Protected]iu weixin]# Touch Test.file
[Email protected] weixin]# echo "123456" > Test.file
[[email protected] weixin]# git Add.
[[email protected] weixin]# git commit-m "This is a test"
[[email protected] weixin]# git push //or Git push-u Origin master
Error:the requested URL returned error:401 unauthorized while accessing http://git.wangshibo.net:8081/weixin/ Weixin.git/info/refs

Fatal:http request failed

Workaround:
In the code of the. git/config file [remote "origin"] URL of the Gitlab domain name before adding Gitlab registration " User name: password @"
As below, Gitlab's username is Wangshibo, assuming the password is [email protected]!h8

To view the login user name in the Gitlab interface:


[[email protected] weixin]# CD. Git
[[email protected]. 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

modified as follows:
[[email protected]. git]# Cat config
[ Core]
Repositoryformatversion = 0
FileMode = True
Bare = False
Logallrefupdates = True
[remote origin] ]
Fetch = +refs/heads/*:refs/remotes/origin/*
URL = http://wangshibo:[email  protected][email protected] git.wangshibo.net:8081/weixin/weixin.git
[branch "master"]
Remote = origin
Merge = Refs/heads/master

Git push upload code to Gitlab, error 401 or 403

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.