版本管理
1、文件管理+历史追踪+冲突管理+版本发布+团队协作
2、维护+开发+研究3代
Git与SVN的不同
SVN集中式配置管理工具,一旦中央仓库的服务器宕掉,提交历史则清空。
- Git的产品:gitlab,github,Bitbucket
- Git如果远程仓库目前不能连,那么本地也可以进行版本管理(commit)
- Git本地拥有服务器镜像,拥有全部的提交历史,本地相当于一个仓库。
- 接口颗粒度变小,职责分配清楚 => 方便分支管理与减少代码冲突,功能解耦
三种角色
1、 配置管理
创建仓库
创建分支
创建基线
2、 资深程序员
Pull Request管理(预合并:在本地仓库做一个当前feater分支到远程develop分支的合并,pull request请求,但是远程并未同意,接着在本地服务器拉取develop分支与feacher分支,并做合并,称为预合并,合并成功之后,pull request有相应的提示)
3、 小白程序员
配置并启动虚拟机的gitlab:

其中右侧的框用于查看本机的IP,命令:If config 查看本机ip,本地ip :

相关配置信息
http://192.168.100.XX:8080
用户名:root
密码:admin123456
sudo docker run --detach \ create与start两个步骤
--hostname 192.168.153.128
--publish 8443:443 --publish 8080:80 --publish 2222:22
--name gitlab --restart always
--volume /srv/gitlab/config:/etc/gitlab
--volume /srv/gitlab/logs:/var/log/gitlab
--volume /srv/gitlab/data:/var/opt/gitlab
beginor/gitlab-ce:11.0.4-ce.0

图中的红色框中为containnerID
登录虚拟机的gitlab网址:
1、在本地的浏览器中输入虚拟机网,输入用户名为root,密码为:admin123456

2、为gitlab添加成员,并配置成员信息,包括姓名、用户名、电子邮箱


3、可以设置某些项目功能并选择访问权限

4、为新创建的项目添加成员并设置成员的角色权限

5、查看某一项目现有的成员


vim /srv/gitlab/config/gitlab.rb
为Gitlab Server配置邮件通知的方法
打开挂载的配置目录
vi /srv/gitlab/config/gitlab.rb
添加外部请求的域名(如果不支持https, 可以改成http)
external_url 'https://gitlab.sun.cc'
修改gitlab对应的时区
gitlab_rails['time_zone'] = 'PRC'
开启邮件支持
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'gitlab@sun.cc'
gitlab_rails['gitlab_email_display_name'] = 'chinamobile GitLab'
配置邮件参数
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.chinamobile.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "gitlab@chinamobile.com"
gitlab_rails['smtp_password'] = "xxxxxx"
gitlab_rails['smtp_domain'] = "chinamobile.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
配置Git客户端参数的方法
1、直接修改.gitconfig文件
C:\Users\XXX.gitconfig
2、使用Tortoise Git客户端配置
右键菜单,“设置”-->"Git"-->“编辑全局.git/config”
配置文件内容为:
[core]
autocrlf = true
excludesfile =
quotepath = false
[push]
default = matching //自动在远程客户端选择与本地对应的分支,不用每次都手动选择
[branch "master"]
rebase = true
[branch "develop"]
rebase = true
[branch "engine"]
rebase = true
[http]
sslVerify = false
打基线+查基线
Git remote –v 查看
git tag -a "0.9_sprint10_2018-8-30" -m "第10个Sprint发布版本"
git tag
git remote -v
git push origin --tags
Gitlab查看Tag

改网址并提交tags:
首先git remote rm origin
然后git remote add origin http://...即实际的远程仓库地址

也可在gitlab上面添加标签,在gitlab服务端打的基线也可以在客户端听过git pull origin –tags 在本地通过git tag 可以查看



操作步骤:
1、在Gitlab创建git仓库
2、在客户端提供项目代码
3、提交项目代码到Gitlab仓库
4、在master分支上打Tag 0.1
5、以Tag 0.1为基础创建develop分支
6、提交两次到develop分支
扩展步骤:以Tag 0.1为基础创建hotfix分支
提交两次到hotfix分支
将hotfix分支合并到develop分支
将hotfix分支合并到master分支
打Tag(0.2)
7、以develop分支为基础创建feature分支
8、提交两次到feature分支
9、发起pull request
10、执行pull request确认,合并到develop分支
11、以develop分支为基础,创建release分支(提测)
12、在release分支上提交两次(模拟bug fix)
13、将release分支合并到develop分支
13、将release分支合并到master分支,并打Tag(1.0)
14、删除feature分支
图片.png
5、以Tag 0.1为基础创建develop分支

6、提交两次到develop分支
本地分支为develop,远端分支输入develop
拉取远程新建的分支方法:
git fetch origin
git checkout –b feather origin/feather //即获取服务端的feather分支,并在本地检出到该分支
网友评论