###Git usage specification, branch, naming convention, and Jenkins deployment and operation
GitLab Flow 是GitLab 官方推荐的分支管理策略,GitLab FLow的最大原则叫做“上游优先”(upstream first),意思是指只能存在一个主分支master,它是其他分支的上游,只有上游分支采纳的代码变化,才能应用到其他的分支。
#### Continuous release
- 根据现有的流程发布,支持按照 tag 或者分支直接拉取代码发布
- prod发布,强制要求按照tag进行发布
#### Branch Conventions
- feature branch
- 功能分支,用于发版的功能开发,开发完成后,合并到test branch 进行功能测试验证)
- 从master分支中来
- 到master/test分支中去
- 命名规范 feature/{功能简述}.{时间}
- test branch
- 测试分支,用于测试环境的发布,测试完成后,需要合并master分支
- 主要用于同时有个并行的功能需要进行测试,测试环境有限,需要将要多个feature合并test分支进行发布测试。
- 从master分支中来。合并到master分支中去
- 命名规范 test/{功能简述}.{时间}
- hotfix branch
- bug修复分支
- 当我们在Production 发现的新的bug的时候,我们需要创建一个Hotfix, 完成hotfix后,我们合并回master
- 从master中来,合并回master
- 命名规范: hotfix/{bug简述}.{时间}
####manual
- 各个项目负责人根据自己的任务从master创建对应的 feature/{功能简述}.{时间} 的分支
- 新建feature branch用于合并到 test 测试分支,发布到测试环境测试
- test 分支测试完成后,合并到master
- feature /test 都是属于临时分支,使用完,定时删除
- 功能分支和修复分支合并进master分支,必须通过 Merge Request。
###code review
- The standards and process of the review must be clear to the person, formulate the process, and be included in the assessment
- the master branch should be protected, not everyone can modify this branch, and have the power to approve Merge Request.
- Operation process, the developer initiates a merge request, and the main owner or leader undertakes the review task
- doule check (main owner & developer)
- Does QA need to intervene in the review process? Check code vulnerabilities through continuous integration, such as: sonarqube
###Code Specification
- Make the red line in the code. Good code design has its own merits, but at least let everyone understand what can't be done and what can't be touched!
- Refer to clean code, refactoring (improving existing code design)
- Tools, Alibaba code specification ideal/eclipse plug-in support
####Other specifications
Message submission specification
[model][action][message]
按照模块,动作,描述 进行规范提交
Precautions
1:尽量避免无意义的提交
2:尽量保证提交的原子性
3:对无意义的提交log进行压缩,保证提交记录的整洁性
4:更新当前分支代码的时候一定要使用 git pull origin xxx --rebase
5:合并代码的时候按照最新分支优先合并为原则
6:要经常从上游分支更新代码,如果长时间不更新上游分支代码容易出现大量冲突
####Common operation commands of Git
Remote warehouse operation command
检出仓库:$ git clone git://github.com/jquery/jquery.git
查看远程仓库:$ git remote -v
添加远程仓库:$ git remote add [name] [url]
删除远程仓库:$ git remote rm [name]
修改远程仓库:$ git remote set-url --push [name] [newUrl]
拉取远程仓库:$ git pull [remoteName] [localBranchName]
推送远程仓库:$ git push [remoteName] [localBranchName]
set branch association
git branch --set-upstream-to=origin/developgit
git checkout -b rstim_socket_service.topic.changjun.20191118 origin/develop 基于远程分支创建分支,并且切换到当前创建的分支
Branch (branch) operation related commands
查看本地分支:$ git branch
查看远程分支:$ git branch -r
创建本地分支:$ git branch [name] ----注意新分支创建后不会自动切换为当前分支
切换分支:$ git checkout [name]
创建新分支并立即切换到新分支:$ git checkout -b [name]
删除分支:$ git branch -d [name] ---- -d选项只能删除已经参与了合并的分支,对于未有合并的分支是无法删除的。如果想强制删除一个分支,可以使用-D选项
合并分支:$ git merge [name] ----将名称为[name]的分支与当前分支合并
huo
创建远程分支(本地分支push到远程):$ git push origin [name]
删除远程分支:$ git push origin :heads/[name] 或 $ gitpush origin :[name]
Related Operation Commands of Version Tag
查看版本:$ git tag
创建版本:$ git tag [name]
删除版本:$ git tag -d [name]
查看远程版本:$ git tag -r
创建远程版本(本地版本push到远程):$ git push origin [name]
删除远程版本:$ git push origin :refs/tags/[name]
合并远程仓库的tag到本地:$ git pull origin --tags
上传本地tag到远程仓库:$ git push origin --tags
创建带注释的tag:$ git tag -a [name] -m 'yourMessage'