简体   繁体   English

Git工作流程和基础

[英]Git Workflow and Rebase

Just starting out with Git and want to start off on the right foot. 刚从Git开始,想要从右脚开始。 I've done some research (eg. Git workflow and rebase vs merge questions , "git pull" or "git merge" between master and development branches ) and a recommended workflow seems to be: 我已经做过一些研究(例如, Git工作流和rebase vs合并问题主分支和开发分支之间的“ git pull”或“ git merge” ),推荐的工作流似乎是:

-One time only: clone central repo to personal repo -仅一次:将中央存储库克隆到个人存储库

-Create a develop branch -创建开发分支

-Do commits on develop branch -在开发分支上提交

-Every so often pull on the master branch (getting changes from central repo) and rebase develop branch on updated master branch if master has indeed been updated -如果主服务器确实已更新,则经常拉主服务器分支(从中央存储库获取更改),并在更新的主服务器分支上重新建立开发分支

-When done developing a feature on the develop branch merge master and develop branch (after pulling on master once again) -在开发分支合并母版和开发分支上完成功能开发后(再次拉上母版之后)

I have a few questions about this: 我对此有一些疑问:

  1. When a rebase fails due to a merge conflict between the updated master branch and your develop branch (from developers editing the same file), should you abort and switch to a merge instead? 当由于更新的master分支和您的dev分支(来自开发者编辑同一文件)之间的合并冲突而导致基准失败时,您应该放弃并切换到合并吗?

  2. Why merge when a feature is complete rather than rebasing again? 为什么在功能完成后合并而不是重新定级?

  3. Should I push as well every time I finish developing a feature or fixing a bug? 每当我完成功能开发或修复错误时,我是否也应该推送?

  1. When you get a conflict during a rebase, you may simply resolve it and continue rebasing. 在重新定级期间遇到冲突时,您可以简单地解决它并继续重新定基。 Aborting and doing a merge instead won't help, you'll still get the conflict anyways. 中止并进行合并无济于事,无论如何您仍然会遇到冲突。

  2. You'll want to merge when you're done with a feature whether you rebase your feature/develop branch on top of master or not. 完成功能后,无论您是否将功能/开发分支重新建立在master之上,都将需要合并。 The difference that a rebase makes beforehand is that it gives you an opportunity to rewrite, structure, shape, and present your history in a (hopefully) clearer way than just doing a merge that results in a merge-commit (also known as a "non-fast-forward" merge). 预先设定基准的区别在于,它可以让您有机会(希望)以更清晰的方式重写,构造,塑造和呈现历史记录,而不仅仅是进行合并而导致合并提交(也称为“非快进”合并)。

    However, some people like to create a merge commit anyways, just to show where a branch occurred. 但是,有些人还是喜欢创建合并提交,只是为了显示分支发生的位置。 You can force a merge commit even after a rebase by using the "non-fast-forward" flag, ie git merge --no-ff . 您甚至可以在重新设置基准之后,通过使用“ non-fast-forward”标志来强制执行合并提交,即git merge --no-ff

  3. Whether to push after finishing a feature or bug fix depends on the project, and how you want to share your code with other people, if you're sharing it at all. 是否在完成功能后还是在漏洞修复后进行推送取决于项目,以及如果您要共享代码,则如何与他人共享代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM