简体   繁体   English

避免合并开发人员的功能分支上的问题,以免混淆主分支的历史记录

[英]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, 问题是,

  1. is there a way we can avoid this systematically ie ask git to reject any changes into master where the change SHA id is actually a rollback. 有没有一种方法可以系统地避免这种情况,即让git拒绝对master的任何更改,而更改SHA id实际上是回滚。
  2. Is there a way during the merge when developers get conflicts only on the files that they have changed 在合并过程中,当开发人员仅对他们已更改的文件产生冲突时,是否有办法

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.

相关问题 将功能分支合并到母版后重写历史记录 - Rewriting history after merging feature branch into master 搞砸了分支,旧的master分支显示了新分支中的文件? - Messing up with branches, old master branch shows files from the new branch? 将变更从master合并到已发布的功能分支中 - merging changes from master into a published feature branch Git - 在开发人员之间将一个功能分支的更改合并到另一个功能分支 - Git - Merging changes from one feature branch into another between developers 正确的方法来清理Git功能分支而不合并到master中? - Proper way to clean up a Git feature branch without merging it into master? 与主站相同时,合并远程分支 - Merging branch on remote when it's identical to master 将功能分支合并到 master 后如何建议开发人员启用 git LFS (git) - How to advice developers after merging feature branch to master to enable git LFS (git) 合并以掌握具有先前共同历史的两个分支 - merging to master two branches with previous common history 为什么将主分支合并到功能分支会从 GIT 中的功能分支中删除文件? - Why merging master branch to feature branch is deleting files from feature branch in GIT? 将主分支合并到功能分支,然后再次返回 - Merging master branch into feature branch then back again
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM