准备环境:172.18.9.200是gitlab、172.18.9.201是jenkins
Git是gitlab的客户端命令,gitlab是应用程序html
rpm包国内下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/nginx
(注:我在此处停留好久,由于我yum时老是报错“Nothing to do”,只要咱们mount上光盘,配好epel源aliyun的镜像便可yum了,由于此时源码包已上传至虚拟机,这时下载源码包已经和yum源不要紧了)git
port=2022 #默认为22,必改web
external_url 'http://172.18.9.150' 此项改成IP,是为了让开发人员能连上咱们。
###Email Settings
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "rooroot@163.com"
gitlab_rails['smtp_password'] = "zhang@123"
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = :login
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['gitlab_email_from'] = "rooroot@163.com"
user["git_user_email"] = rooroot@"163.com" 该处的“”必须加上,sql
[root@200 ~]#gitlab-
gitlab-ctl gitlab-psql gitlab-rails gitlab-rake vim
run: alertmanager: (pid 30017) 149s; run: log: (pid 29629) 188s
run: gitaly: (pid 29893) 154s; run: log: (pid 28314) 338s
run: gitlab-monitor: (pid 29950) 153s; run: log: (pid 29390) 212s
run: gitlab-workhorse: (pid 29911) 154s; run: log: (pid 29077) 243s
run: logrotate: (pid 29207) 233s; run: log: (pid 29228) 230s
run: nginx: (pid 29144) 239s; run: log: (pid 29167) 236scentos
[root@200 src]#ntpdate 172.18.0.1
23 Apr 11:41:27 ntpdate[32929]: adjust time server 172.18.0.1 offset -0.188343 sec
[root@200 src]#gitlab-ctl restart
ok: run: alertmanager: (pid 32972) 0s
ok: run: gitaly: (pid 32987) 0s
ok: run: nginx: (pid 33037) 1s服务器
[root@201 ~]#git clone http://172.18.9.150/web35/web1.git
Cloning into 'web1'...
Username for 'http://172.18.9.150': Leslie #这是name
Password for 'http://Leslie@172.18.9.150':
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@201 ~]#ll
total 12
drwxr-xr-x. 3 root root 36 Apr 23 12:23 web1
[root@201 ~]#cd web1/
[root@201 web1]#ll
total 4
-rw-r--r--. 1 root root 23 Apr 23 12:23 index.html
[root@201 web1]#vim index.html
马哥教育Linux 35 v1dom
[root@201 ~]#git config --global user.name "user1"
[root@201 ~]#git config --global user.email "test.@qq.com"
[root@201 ~]#cd web1/
[root@201 web1]#vim index.html
马哥教育 Linux 35 v1
马哥教育 Linux 35 v2
[root@201 web1]#git add ./*
[root@201 web1]#git commit -m "v2"
[master ca130ab] v2
1 file changed, 2 insertions(+), 1 deletion(-)
[root@201 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:ssh
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://172.18.9.150': Leslie
Password for 'http://Leslie@172.18.9.150':
Counting objects: 5, done.
Writing objects: 100% (3/3), 258 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://172.18.9.150/web35/web1.git
3af0975..ca130ab master -> master #默认是master
Switched to a new branch 'develop'
[root@201 web1]#git branch
develop
master
{插播:如何寻找develop分支的clone}:
步骤:Groups,web35,web1,点击“+”,建立新branch,再返回web1点击“clone”,便可!!
[root@200 src]#git clone -b develop http://172.18.9.150/web35/web1.git
Cloning into 'web1'...
Username for 'http://172.18.9.150': Leslie
Password for 'http://Leslie@172.18.9.150':
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
马哥教育Linux 35 v1
马哥教育Linux 35 v2
马哥教育Linux 35 v3 #这些内容只有通过测试才会被发布到线上
[develop 89e511c] v3
1 file changed, 2 insertions(+)
[root@200 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://172.18.9.150': Leslie
Password for 'http://Leslie@172.18.9.150':
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 266 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote:
remote: To create a merge request for develop, visit:
remote: http://172.18.9.150/web35/web1/merge_requests/new?merge_request%5Bsource_branch%5D=develop
remote:
To http://172.18.9.150/web35/web1.git
ca130ab..89e511c develop -> develop
回滚到v1:
git config --globaluser.name “name“ #设置全局用户名git config --globaluser.email xxx@xx.com#设置全局邮箱git config --global –list #列出用户全局设置git add index.html / . #添加指定文件、目录或当前目录下全部数据到暂存区git commit -m“11“ #提交文件到工做区gitstatus #查看工做区的状态git push #提交代码到服务器git pull #获取代码到本地gitlog #查看操做日志vim . gitignore #定义忽略文件基于仓库的回滚:git reset --hard HEAD^^ #git 版本回滚, HEAD 为当前版本,加一个^为上一个,^^为上上一个版本gitreflog # #获取每次提交的 ID,能够使用--hard 根据提交的 ID 进行版本回退gitreset --hard 5ae4b06 #回退到指定 id 的版本#git branch #查看当前所处的分支#git checkout -b develop #建立并切换到一个新分支#git checkout develop #切换分支