一. 代码协作开发步骤
具体步骤命令行示例(也可以使用TortoiseGit工具)
注意命令中工号改为自己的工号
<http://gitlab.htzq.htsc.com.cn/cams/cams_app#0-%E5%87%86%E5%A4%87>0. 准备
设置用户名为自己的工号, 否则无法提交代码
git config --global user.name "012829" git config --global user.email
"[email protected]"
<http://gitlab.htzq.htsc.com.cn/cams/cams_app#1-fork>1. Fork
将当前仓库fork到个人仓库下,例如http://gitlab.htzq.htsc.com.cn/012829/cams_app
<http://gitlab.htzq.htsc.com.cn/cams/cams_app#2-clone>2. clone
clone代码到本地
git clone [email protected]:012829/cams_app.git
<http://gitlab.htzq.htsc.com.cn/cams/cams_app#3-%E8%AE%BE%E7%BD%AEupstream>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)
<http://gitlab.htzq.htsc.com.cn/cams/cams_app#4-commit>4. commit
详见GitLab提交规范
<http://wiki.htzq.htsc.com.cn/pages/viewpage.action?pageId=22275447>
git commit -am "#XYPJ-2281#corrent message example"
<http://gitlab.htzq.htsc.com.cn/cams/cams_app#5-git-fetch>5. git fetch
fetch主仓库代码到本地(注意: 只是获取,还未合并)
git fetch upstream
<http://gitlab.htzq.htsc.com.cn/cams/cams_app#6-git-merge>6. git merge
以合并master分支的代码为例,其他分支类似处理
* 本地代码切换到master分支(如果已经在master分支就跳过这一步)
* 合并主仓库的master分支到本地的master分支 shellgit checkout mastergit merge upstream/master
<http://gitlab.htzq.htsc.com.cn/cams/cams_app#7-git-push>7. git push
git push origin master
<http://gitlab.htzq.htsc.com.cn/cams/cams_app#8-merge-request>8. Merge Request
在GitLab的个人项目主页发起merge request, 提交代码到主仓库对应的分支。
热门工具 换一换