gitlab
gitlab
https://docs.gitlab.com/omnibus/manual_install.html
https://packages.gitlab.com/gitlab/gitlab-ce
若下载速度慢,可以下面的地址
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
安装
yum install gitlab-ce-11.9.9-ce.0.el7.x86_64.rpm
配置 github,主要是更改服务器地址和邮件发送功能,在后期用户注册和账户密码找回使用
[root@Final gitlab]# grep "^[a-Z]" /etc/gitlab/gitlab.rb
external_url 'http://192.168.10.254' #项目服务器地址
gitlab_rails['smtp_enable'] = true #邮件发送设置
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "rootroot@qq.com"
gitlab_rails['smtp_password'] = "password"
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = :login
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['gitlab_email_from'] = "rootroot@qq.com"
user["git_user_email"] = "rootroot@qq.com"
配置并启动 github 服务,如果配置文件发生更改需要重新执行此命令:
gitlab-ctl reconfigure
查看 gitlib 状态
gitlab-ctl status
访问 web 界面
#如打开以后是 502 的界面,需要检查 80 和 8080 端口是否被占用,另外增加内存
登录系统
默认登录名是root,密码是刚才改的密码
把注册功能去掉,然后点保存更改
建立一个用户
修改密码
建立团体
创建一个项目
在项目做一个测试页面
把刚才建立的用户加入这个组里
查看连接
客户端git
yum install git -y
[root@node ~]# git clone http://192.168.10.254/web233/web1.git
Cloning into 'web1'...
Username for 'http://192.168.10.254': user1
Password for 'http://user1@192.168.10.254':
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
[root@node ~]# ls
anaconda-ks.cfg web1
[root@node ~]# cat web1/index.html
this is web233 test v1...
ls /root/web1/.git/config
git常用命令
git config-global user.name "name" #设置全局用户名
git config-global user.email xxx@xx.com #设置全局邮箱
git config-global --list #列出用户全局设置
git addindex.html/. #添加指定文件、目录或当前目录下所有数据到暂存区
git commit -m "v1" #提交文件到工作区gitstatus#查看工作区的状态
git push #提交(上传)代码到服务器
git pull #获取(下载)代码到本地
git log #查看操作日志
vim .gitignore #定义忽略文件
git reset --hard HEAD^^ #git版本回滚,HEAD为当前版本,加一个A为上一个,AM为上上一个版本。
git reflog ##获取每次提交的ID,可以使用-hard根据提交的ID进行版本回退
git reset --hard cb778a8 #回退到指定id的版本
#git branch #查看当前所处的分支
#git checkout -b develop #创建并切换到一个新分支
#git checkout develop #切换分支
[root@node web1]# git config --global user.name "user1"
[root@node web1]# git config --global user.email "user1@qq.com"
[root@node web1]# git config --global --list
user.name=user1
user.email=user1@qq.com
#注这不是gitlab真实用户和邮箱
提交代码到服务器
[root@node web1]# cat index.html
this is web233 test v1...
this is web233 test v2...
[root@node web1]# git add ./*
[root@node web1]# git commit -m "v2"
[master f196b3e] v2
1 file changed, 2 insertions(+), 1 deletion(-)
[root@node web1]# 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.10.254': user1
Password for 'http://user1@192.168.10.254':
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 257 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://192.168.10.254/web233/web1.git
1eb3214..f196b3e master -> master
[root@node web1]# git status
# On branch master
nothing to commit, working directory clean
更新代码
[root@node web1]# git pull
Username for 'http://192.168.10.254': user1
Password for 'http://user1@192.168.10.254':
查看操作日志
[root@node web1]# git log
commit f196b3e1f10238beb9a99ea9cf543e8d7e988d8d
Author: user1 <user1@qq.com>
Date: Wed Jul 17 15:20:18 2019 +0800
v2
commit 1eb3214d4045a5c375a6bdb3855a6629427fa6cb
Author: Administrator <admin@example.com>
Date: Wed Jul 17 14:13:24 2019 +0800
web233 test v1
回滚操作
先上传一个版本
git add ./*
git commit -m "v3"
git push
回滚上一个版本
[root@node web1]# git reset --hard HEAD^
HEAD is now at f196b3e v2
[root@node web1]# git reflog
f196b3e HEAD@{0}: reset: moving to HEAD^
cb778a8 HEAD@{1}: commit: v3
f196b3e HEAD@{2}: commit: v2
1eb3214 HEAD@{3}: clone: from http://192.168.10.254/web233/web1.git
[root@node web1]# cat index.html
this is web233 test v1...
this is web233 test v2...
查看版本
[root@node web1]# git reflog
f196b3e HEAD@{0}: reset: moving to HEAD^
cb778a8 HEAD@{1}: commit: v3
f196b3e HEAD@{2}: commit: v2
1eb3214 HEAD@{3}: clone: from http://192.168.10.254/web233/web1.git
[root@node web1]# git reset --hard cb778a8
HEAD is now at cb778a8 v3
查看当前分支
[root@node web1]# git branch
* master
先建立一个分支
[root@node web1]# git branch
* master
[root@node web1]# git checkout
[root@node web1]# git checkout -b develop
Switched to a new branch 'develop'
[root@node web1]# git branch
* develop
master
[root@node web1]# git clone -b develop http://192.168.10.254/web233/web1.git
上传一个版本
[root@node web1]# git add ./*
[root@node web1]# git commit -m "v4"
[develop b1ec822] v4
1 file changed, 1 insertion(+)
create mode 160000 web1
[root@node web1]# 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.10.254': user1
Password for 'http://user1@192.168.10.254':
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 248 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
remote:
remote: To create a merge request for develop, visit:
remote: http://192.168.10.254/web233/web1/merge_requests/new?merge_request%5Bsource_branch%5D=develop
remote:
To http://192.168.10.254/web233/web1.git
cb778a8..b1ec822 develop -> develop