项目开发环境搭建手记(3.GitLab搭建)

本文详述了在Centos系统中安装Git和GitLab的步骤,包括安装Git、配置GitLab、创建代码仓库、解决权限及SSH访问问题。文中还介绍了在遇到错误时的排查和解决方案,如SSH公钥、防火墙设置、端口冲突及GitLab与Nginx的集成。最后,文章提及了项目开发环境中的团队协作配置,如用户权限管理和域名设置。
摘要由CSDN通过智能技术生成

作者:fbysss
QQ:溜酒酒吧酒吧吾散
blog:blog.csdn.net/fbysss
声明:本文由fbysss原创,转载请注明出处
 

一、git安装

Centos下面,就是这么任性:

yum install git

中间有2步需要输入y确认一下。

其他操作系统方法:http://git-scm.com/download/linux

安装完成后,

git --version

git version 1.7.1

验证成功。

 

二、.gitlab安装

GitLab是很接近Github的,而且免费,所以选择它作为项目代码仓库。地址:https://about.gitlab.com/downloads/

 选择操作系统之后,会有一步步的提示。当然,有些已经有了的,就不用再安装了。可以用whereis检查一下

 curl-O https://downloads-packages.s3.amazonaws.com/centos-6.6/gitlab-7.6.2_omnibus.5.3.0.ci-1.el6.x86_64.rpm

 (curl的-O指的是把url这里的东西直接输出到文件中,文件名默认就是url中的文件名。)

  

sudo rpm -igitlab-7.6.2_omnibus.5.3.0.ci-1.el6.x86_64.rpm

sudo gitlab-ctl reconfigure

sudo lokkit -s http -s ssh

这句是用来做防火墙的。避免用户通过ssh方式和http来访问

按照步骤做了之后,访问http://localhost就可以进入登录界面了。

默认账号:

Username: root
Password: 5iveL!fe

 

进去之后就要设置新的密码,随便写一个sss54321

 

进来之后,可以create a new project

然后会发现,硬盘上已经生成了一个git文件: /var/opt/gitlab/git-data/repositories/root/sssApp.git

也看到了url http://localhost.localdomain:9999/root/sssApp.git

此时,在客户机中,也可以clone一下试试:

git clone http://192.168.0.12:9999/root/sssApp.git 

正常。warning: You appear to have cloned an empty repository.很显然,啥也没有,只是一个空仓库。

/opt/gitlab/embedded/etc/gitconfig

 

[sss@localhost ~]$sudo git config --list
fatal: error processing config file(s)

touch ~/.gitconfig

OK。

 

——自己装过一个git,gitlab也内嵌一个。但两者显然没有关联。安装好了居然没有配置文件?啥情况。

实际上也无所谓,只不过提示信息太吓唬人了。

rm ~/.gitconfig

git config--global color.diff auto

然后再看,文件已经自动生成了。

三、创建代码仓库:

su root

mkdir /repo/sssApp

cd /repo/sssApp

git init

git remote add originhttp://localhost.localdomain:9999/root/sssApp.git

git push -u origin master

 

error: The requested URL returned error: 401 Unauthorized while accessing http://localhost.localdomain:9999/root/sssApp.git/info/refs

 

git config--list发现 remote.origin.url=http://localhost.localdomain:9999/root/sssApp.git

git config -e可以进行修改

 

网上很多帖子说,升级版本之后就OK,或者换SSH方式,在我看来都是不知其所以然。

其实错误提示的已经很清楚了,就是需要认证。

这啦唯一需要大家注意的,就是这里的用户名,应该是gitlab的用户名,与linux主机无关。

正确的做法:

 remote.origin.url=http://localhost.localdomain:9999/root/sssApp.git

修改为 remote.origin.url=http://root:rootpassword@localhost.localdomain:9999/root/sssApp.git

再试就OK了。

但是问题又来了,这样把密码明文写在这里,显然不是太好。

重新来一遍,新建一个目录和库

mkdir  /repo/justtest

cd  /repo/justtest

git init 

git remote add origin http://root@localhost.localdomain:9999/root/justtest.git

git push -u origin master

 

(gnome-ssh-askpass:5430):Gtk-WARNING **: cannot opendisplay: 

看来是显示的问题。于是直接到Centos下,进入终端执行

这下弹出一个图形化窗口,要我输入密码。

但输入之后提示

error: src refspec master does not match any.
error: failed to push some refsto'http://root@localhost.localdomain:9999/root/

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值