Git workflow:fork-and-pull

背景:

产品的主库在“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

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Work on your fork
    1. Make your changes and additions
    2. Change or add tests if needed
    3. Run tests and make sure they pass
    4. Add changes to README.md if needed
  4. Commit changes to your own branch
  5. Make sure you merge the latest from "upstream" and resolve conflicts if there is any
  6. Repeat step 3(3) above
  7. Push your work back up to your fork
  8. Submit a Pull request so that we can review your changes

参考:
Git Tip: Rebase Your Stash

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容