在 GIT 上手动合并 [英] Manual merge on GIT

查看:34
本文介绍了在 GIT 上手动合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用专有脚本语言进行开发,其中大部分配置都包含在代码本身中.

明显的问题是测试环境和生产环境之间代码本身的差异,而这正是我试图用 GIT 管理的问题.

由于我的测试环境非常不稳定,我想我可以在进行更改时在 GIT 中为它创建一个分支(并在其中保留带有测试配置的代码),在代码被接受后我会合并它投入生产.

好吧,当我要求 git 合并我的分支时,它在代码方面做得很好..但是配置也被迁移了,然后我必须逐个打开文件,将其改回原来的状态.

无论如何我可以禁用来自 GIT 的自动合并并威胁所有内容作为代码冲突以手动与 WinMerge 合并或稍后?代码很短,真的.而且因为无论如何我都必须编辑它以应用配置...

ps.:请注意,我不是在问如何在 git 上配置 WinMerge.我有这些工具在工作.我的问题是如何始终在分支之间执行手动合并.

谢谢!

f.

解决方案

禁用自动合并

这可以通过编写一个小的合并驱动程序来实现,设置在 a .gitattributes文件.
unset 之类的政策可能正是您所需要的.

未设置

<块引用>

以当前分支的版本作为暂定合并结果,声明合并有冲突.这适用于没有明确定义的合并语义的二进制文件.

但另一个有趣的 gitattribute 驱动程序是 clean filer:

这会在将清理过的"内容提交到存储库之前自动执行您选择的清理"脚本.
这样的clean"脚本可以帮助您自动执行必须对代码进行的更改,以保留或修改其中嵌入的配置值.

I develop in a proprietary script language with very resumed code in which most configurations are contained inside the code itself.

The obvious problem would be the differences in the code itself between test and production environments and that's exactly what I'm trying to manage with GIT.

As my test env is quite volatile I figured I could create a branch in GIT for it while there are changes being made (and keep the code with test configurations in there) and after the code has been accepted I'd merge it into production.

Well, when I ask git to merge my branches it does a wonderful job with the code.. but the configs are migrated as well and than I have to open file-by-file, changing it back to what it was.

Is there anyway I could disable the automatic merge from GIT and threat everything as code conflicts to be manually merged with WinMerge or something later? The code is short, really. And since I'm gonna have to edit it anyway to apply the configurations...

ps.: please notice, I'm not asking how to configure WinMerge on git. I have these tools working. My question is how to always perform manual merges between branches.

thanks!

f.

解决方案

disable the automatic merge

That could be achieve by writing a small merge driver, set in a .gitattributes file.
A policy like unset might be what you are looking for.

Unset

Take the version from the current branch as the tentative merge result, and declare that the merge has conflicts. This is suitable for binary files that does not have a well-defined merge semantics.

But another interesting gitattribute driver would be a clean filer:

That would automatically execute a 'clean' script of your choice just before committing the "cleaned" content to the repo.
Such a 'clean' script could help you automate the changes you have to make to your code to keep or modify the config values embedded in it.

这篇关于在 GIT 上手动合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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