git策略有一组提交限于特定的分支 [英] git strategy to have a set of commits limited to a particular branch

查看:134
本文介绍了git策略有一组提交限于特定的分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要经常在dev和master之间合并。



我也有一个提交,我只需要将其应用于开发,以便在本地工作。

p>

之前我只从开发人员合并到master,所以我有一个分支production_changes,它包含dev特殊提交的撤消提交。并从主人,我合并了这一点。用于正常工作。



现在,每次我从开发人员合并到主开发人员,反之亦然,我必须一次又一次地樱桃挑选并应用相同的提交:( 。哪些是UGLY。



我可以采取什么策略,以便我可以在2个分支之间无缝合并,但只保留其中一个分支的某些更改? p>

解决方案

我会推荐一个 (脚本在中的合并指令中声明的脚本)。 gitattributes 文件),以防止某些文件受到给定提交的影响。

(例如,如果某些文件不能被修改,那么该驱动程序将非常简单a
keep mine合并。这已被用于通过示例合并仅限特定目录,或者跟踪<每个分支管理一个配置文件。 )



THE OP增加:


但我寻找更聪明解决方案,如果存在的话,比如创建一个只有撤消提交的分支,并将其应用于主设备,将设备假设为开发设备。

聪明的解决方案?...

那么我可以建议 git rerere (重复使用冲突合并的记录分辨率:如果合并到开发器会触发冲突,如果该冲突的解决方案是您有效取消合并,则可以按顺序记录该分辨率让它在下一次合并时自动重复。



请参阅通过 Scott Chacon 获取更多内容这个命令。


I need to merge between dev and master frequently.

I also have a commit that I need to apply to dev only, for things to work locally.

Earlier I only merged from dev to master, so I had a branch production_changes that contained the "undo commit" of the dev special commit. and from the master, I merged this. Used to work fine.

Now each time I merge from dev to master and vice versa, I am having to cherry-pick and apply the same commit again and again :(. Which is UGLY.

What strategy can I adapt so that I can seamlessly merge between 2 branches, yet retain some of the changes only on one of those branches?

解决方案

I would recommend a merge driver (scripts declared in a merge directive within a .gitattributes file) in order to prevent certain files to be affected by a given commit.
(for instance, if certain files must not be modified, that driver would be as simple as a "keep mine" merge. That has been used to merge only specific directories by example, or to track how config files are managed per branch.)

THE OP adds:

But I am looking more for a clever solution, if one exists, like "create a branch that has the undo commit only and apply it to master, fake it on dev"

Clever solution?...
Well I can propose git rerere (reuse recorded resolution of conflicted merge: if you merge to dev trigger a conflict, and if the resolution of that conflict is you effectively cancelling that merge, you can record that resolution, in order to have it automatically repeated during the next merge.

See Rerere Your Boat... by Scott Chacon for more in this command.

这篇关于git策略有一组提交限于特定的分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆