背景:
产品的主库在“192.168.8.18:3000/product-master”,小组成员从此处fork一份到192.168.8.18:3000/MyName/product-master,经常要用到pull、push操作,主库和自己名称的库之间经常会冲突。
提交流程:
// 1. 临时提交本地修改到local库
$ git add --all // 添加所有修改的文件
$ git commit -m '[STASH]' // 提交当前内容,备注为STASH
// 2. 获取远端服务器上的变更
$ git pull --rebase upstream master
// 3. 处理冲突
# fix conflict (rebase) if needed and then run "git rebase --continue"
# 如果直接修改的原文件,不是通过命令行或者merge工具,需要执行 "git add -u"
// 4. 删除上一次提交,即备注为[STASH]的提交,修改的内容会保留
$ git reset HEAD~1
// 5. Commit and push to your fork
$ git add --all // 添加所有修改的文件
$ git commit -m '说明' // 提交最终变更的内容
$ git push --force origin master // 强制提交,将主库的变更也push到自己的库
// 6. Submit a Pull Request
- Fork the repo on GitHub
- Clone the project to your own machine
- Work on your fork
- Make your changes and additions
- Change or add tests if needed
- Run tests and make sure they pass
- Add changes to README.md if needed
- Commit changes to your own branch
- Make sure you merge the latest from "upstream" and resolve conflicts if there is any
- Repeat step 3(3) above
- Push your work back up to your fork
- Submit a Pull request so that we can review your changes