[英]Avoid merging issues on developers's feature branches from messing up master branch's history
We recently migrated from SVN -> Git (using Stash) . 我们最近从SVN-> Git迁移(使用Stash)。 After the migration , we have started seeing issues during merge where some developers are messing up the merge on their feature branch.
迁移之后,我们开始看到合并期间的问题,其中一些开发人员在其功能分支上弄乱了合并。
**Our workflow model:-**
master 1---2----3------------4----5
| | | | | |
| | M | | |
feature1 | a--------b--- | |
| M |
feature2 c-----------------d-------
In the above figure lets say developer1 has a feature branch feature1 , has done his changes and merged back to develop. 在上图中,可以说developer1具有一个功能分支feature1,进行了更改并合并回去进行开发。
Developer2 has a branch that was created before developer1's branch but is going to be around for a longer time. Developer2有一个分支,该分支是在developer1的分支之前创建的,但是会存在更长时间。 Once the changes are done, he pulls in changes from master into his branch , resolves any conflicts and then merges back in.
更改完成后,他将更改从master引入分支,解决所有冲突,然后合并回去。
The problem is that when developer2 merges changes into his local branch he is resolving merge conflicts by preferring his own files. 问题是,当developer2将更改合并到其本地分支中时,他正在通过偏爱自己的文件来解决合并冲突。 However, this is actually overriding some of the files that he has not changed .
但是,这实际上覆盖了他未更改的某些文件。 When he creates a pull request and merges back to master, he effectively rolls back the changes of developer1 to the previous version.
当他创建拉取请求并合并回master时,他有效地将developer1的更改回滚到了先前的版本。 We can fire this out because the file actually rolls back to the previous commit (SHA) id
我们可以将其触发,因为文件实际上会回滚到上一个提交(SHA)id
The question is, 问题是,
My googling brought me to articles which suggested doing a git pull with the --rebase option or changing the permission on master branch so that they will only allow fast-forward merges. 我的Google搜索使我读到一些文章,这些文章建议使用--rebase选项进行git pull或更改master分支的权限,以便它们仅允许快速合并。 Will either of the options helps.
这些选项中的任何一个都会有所帮助。
Welcome to git. 欢迎来到git。 this is where you realise it's not magic, merging issues haven't disappeared, and you still need to merge like you always did.
在这里,您会意识到这不是魔术,合并问题并未消失,您仍然需要像往常一样进行合并。
The answer is to ensure developers merge correctly, and no tool in the world will force you to do that. 答案是确保开发人员正确合并,并且世界上没有任何工具会强迫您这样做。 It's a people problem ultimately.
最终这是一个人的问题。
I would recommend code reviews that are mandatory for all push requests back to origin, or merging to master. 我建议对所有回溯到原始请求或合并到主请求的推送请求都必须进行的代码审查。 One of the reviews will be to inspect the history to see if any such overrides has occurred with appropriate censures.
审查之一将是检查历史记录,以查看是否有任何这样的超驰发生并受到适当的谴责。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.