一. 代码协作开发步骤
具体步骤命令行示例(也可以使用TortoiseGit工具)
注意命令中工号改为自己的工号
0. 准备
设置用户名为自己的工号, 否则无法提交代码
git config --global user.name "012829"
git config --global user.email "xx.com"
1. Fork
将当前仓库fork到个人仓库下,例如http://gitlab.xx.xx.com.cn/xx/xx
2. clone
clone代码到本地
git clone git@gitlab.xx.xx.com.cn:012829/xx.git
3. 设置upstream
设置主仓库cams/cams_app
为本地仓库的upstream
git remote add upstream git@gitlab.xx.xx.com.xx/xx.git
## 查看设置结果
git remote -v
## 结果
origin git@gitlab.xx.xx.com.cn:012829/xx.git (fetch)
origin git@gitlab.xx.xx.com.cn:012829/xx.git (push)
upstream git@gitlab.xx.xx.com.xx/xx.git (fetch)
upstream git@gitlab.xx.xx.com.xx/xx.git (push)
4. commit
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, 提交代码到主仓库对应的分支。