一、了解branch/master
首先要使用merge request,必须要了解branch/master的概念;
A branch is a version of a project’s working tree. You create a branch for each set of related changes you make. This keeps each set of changes separate from each other, allowing changes to be made in parallel, without affecting each other.
详情可参考官方文档,这里不做详细介绍:
https://docs.gitlab.com/ee/user/project/repository/branches/
可以将master理解为default branch
二、创建branch
可通过追踪issues创建branch,也可直接clone master之后git branch
[lingkai.meng@etxnode01 menglingkai_test]$ git
b ca ci co cp dt l pl ps st
[lingkai.meng@etxnode01 menglingkai_test]$ git b test_0331
[lingkai.meng@etxnode01 menglingkai_test]$ git add .
[lingkai.meng@etxnode01 menglingkai_test]$ git co -m "test_0331"
D a
A adduser_sh/abc.csv
A adduser_sh/projects_add.py
D adgdg
A playbook/playbook_chrony.ymal
A playbook/playbook_zabbix.ymal
Switched to branch 'test_0331'
[lingkai.meng@etxnode01 menglingkai_test]$ git ps origin test_0331
Total 0 (delta 0), reused 0 (delta 0)
remote:
remote: To create a merge request for test_0331, visit:
remote: http://***/lingkai.meng/menglingkai_test/-/merge_requests/new?merge_request%5Bsource_branch%5D=test_0331
remote:
To http://***/lingkai.meng/menglingkai_test.git
* [new branch] test_0331 -> test_0331
[lingkai.meng@etxnode01 menglingkai_test]$
三、提交merge request
确认branch代码准确无误之后,可提交代码到master供大家使用
请注意设置 assignee 以及 Reviewer
不建议大家对source branch做删除操作
命令行操作
heck out, review, and merge locally
Step 1. Fetch and check out the branch for this merge request
git fetch origin
git checkout -b "test_0331" "origin/test_0331"
Step 2. Review the changes locally
Step 3. Merge the branch and fix any conflicts that come up
git fetch origin
git checkout "master"
git merge --no-ff "test_0331"
Step 4. Push the result of the merge to GitLab
git push origin "master"