GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务
gitlab下载链接
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
更新yum源
yum update -y
上传解压(比较慢...)
[root@docker ~]# rpm -ivh gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
warning: gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27e
ab47: NOKEYPreparing... ################################# [100%]
Updating / installing...
1:gitlab-ce-10.0.0-ce.0.el7 ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ \`/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
根据提示修改配置文件
/etc/gitlab/gitlab.rb
#external_url 'http://gitlab.example.com' 将域名改成对应的ip地址 external_url 'http://192.168.1.38'
执行命令(配置东西有点多,不报错的话耐心等待)
gitlab-ctl reconfigure
......
- execute the ruby block reload gitlab-monitor svlogd configuration
Recipe: gitlab::redis-exporter
* ruby_block[reload redis-exporter svlogd configuration] action create
- execute the ruby block reload redis-exporter svlogd configuration
Recipe: gitlab::prometheus
* service[prometheus] action restart
- restart service service[prometheus]
* ruby_block[reload prometheus svlogd configuration] action create
- execute the ruby block reload prometheus svlogd configuration
Recipe: gitlab::postgres-exporter
* service[postgres-exporter] action restart
- restart service service[postgres-exporter]
* ruby_block[reload postgres-exporter svlogd configuration] action create
- execute the ruby block reload postgres-exporter svlogd configuration
Running handlers:
Running handlers complete
Chef Client finished, 360/515 resources updated in 03 minutes 50 seconds
gitlab Reconfigured!
[root@docker ~]#
启动gitlab服务
[root@docker ~]# gitlab-ctl restart
ok: run: gitaly: (pid 18240) 0s
ok: run: gitlab-monitor: (pid 18258) 1s
ok: run: gitlab-workhorse: (pid 18297) 0s
ok: run: logrotate: (pid 18305) 1s
ok: run: nginx: (pid 18310) 0s
ok: run: node-exporter: (pid 18313) 0s
ok: run: postgres-exporter: (pid 18318) 0s
ok: run: postgresql: (pid 18326) 0s
ok: run: prometheus: (pid 18338) 0s
ok: run: redis: (pid 18347) 1s
ok: run: redis-exporter: (pid 18352) 0s
ok: run: sidekiq: (pid 18357) 0s
ok: run: unicorn: (pid 18366) 0s
[root@docker ~]# systemctl stop firewalld
ip地址访问测试
默认用户是root,密码是刚才设置的
选择public级别,然后点击create project 会跳转到如下页面
#安装git工具
[root@docker git]# yum install -y git
[root@docker ~]# mkdir /git
[root@docker ~]# cd git
#等到项目的目录
[root@docker git]# git clone http://192.168.1.38/yhd/yhd.git
Cloning into 'yhd'...
warning: You appear to have cloned an empty repository.
[root@docker git]# cd yhd/
#在项目中编辑或者上传文件到该目录下
[root@docker yhd]# echo 123456 > a.txt
[root@docker yhd]# ls
a.txt
#添加文件到git中
[root@docker yhd]# git add a.txt
[root@docker yhd]# git add *
#查看git上传文件的状态
[root@docker yhd]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: a.txt
#添加用户名和email地址
[root@docker yhd]# git config --global user.name "yhd"
[root@docker yhd]# git config --global user.email "yhd@163.com"
#提交文件
[root@docker yhd]# git push #执行完看到下面提示需指明master,第一次提交需要执行master
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Username for 'http://192.168.1.38': yhd
Password for 'http://yhd@192.168.1.38':
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
Everything up-to-date
[root@docker yhd]# git push origin master
Username for 'http://192.168.1.38': yhd
Password for 'http://yhd@192.168.1.38':
Counting objects: 3, done.
Writing objects: 100% (3/3), 203 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://192.168.1.38/yhd/yhd.git
* [new branch] master -> master
[root@docker yhd]#
页面查看文件是否提交成功
同一项目中再次提交不用执行master验证:
[root@docker yhd]# touch b.txt
[root@docker yhd]# echo test>b.txt
[root@docker yhd]# git add b.txt
[root@docker yhd]# git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: b.txt
#
[root@docker yhd]# git commit -m 'add b.txt'
[master e517e58] add b.txt
1 file changed, 1 insertion(+)
create mode 100644 b.txt
[root@docker yhd]# git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Username for 'http://192.168.1.38': yhd
Password for 'http://yhd@192.168.1.38':
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 255 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://192.168.1.38/yhd/yhd.git
572ed46..e517e58 master -> master