Gitlab团队成员操作步骤

一. 代码协作开发步骤

具体步骤命令行示例(也可以使用TortoiseGit工具)

注意命令中工号改为自己的工号

0. 准备

设置用户名为自己的工号, 否则无法提交代码

git config --global user.name "012829"
git config --global user.email "[email protected]"

1. Fork

将当前仓库fork到个人仓库下,例如http://gitlab.htzq.htsc.com.cn/012829/cams_app

2. clone

clone代码到本地

git clone [email protected]:012829/cams_app.git

3. 设置upstream

设置主仓库cams/cams_app为本地仓库的upstream

git remote add upstream [email protected]:cams/cams_app.git

## 查看设置结果
git remote -v

## 结果
origin  [email protected]:012829/cams_app.git (fetch)
origin  [email protected]:012829/cams_app.git (push)
upstream        [email protected]:cams/cams_app.git (fetch)
upstream        [email protected]:cams/cams_app.git (push)

4. commit

详见GitLab提交规范

git commit -am "#XYPJ-2281#corrent message example"

5. git fetch

fetch主仓库代码到本地(注意: 只是获取,还未合并)

git fetch upstream

6. git merge

以合并master分支的代码为例,其他分支类似处理

  • 本地代码切换到master分支(如果已经在master分支就跳过这一步)
  • 合并主仓库的master分支到本地的master分支 shellgit checkout mastergit merge upstream/master

7. git push

git push origin master

8. Merge Request

在GitLab的个人项目主页发起merge request, 提交代码到主仓库对应的分支。 

猜你喜欢

转载自blog.csdn.net/ruanhao1203/article/details/80440925