GIT 上的手动合并

发布于 2024-09-05 18:39:15 字数 458 浏览 3 评论 0原文

我使用专有的脚本语言进行开发,代码非常恢复,其中大多数配置都包含在代码本身内。

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

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

好吧,当我要求 git 合并我的分支时,它对代码做了出色的工作..但是配置也被迁移了,而且我必须逐个文件打开,将其更改回原来的样子。

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

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

谢谢!

f.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只是在用心讲痛 2024-09-12 18:39:15

禁用自动合并

这可以通过编写一个小型合并驱动程序来实现,在 a .gitattributes< 中设置/code> 文件
unset 这样的策略可能就是您正在寻找的。

Unset

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

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

http://git-scm.com/figures/18333fig0703-tn.png

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

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:

http://git-scm.com/figures/18333fig0703-tn.png

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.

山川志 2024-09-12 18:39:15

您说“大多数配置都包含在代码本身中”,但希望所有配置都隔离在特定于配置的文件中。如果是这种情况,您可以将配置代码的测试和发布案例保留在同一分支中。然后,您可以使用命令行开关来使用测试配置而不是普通配置。

如果您的程序可以从命令行(或环境变量、注册表项、文本文件或其他内容)读取配置选择,那么您根本不必合并。当命令行开关不存在时,程序可以忽略测试配置文件;当命令行开关存在时,程序可以忽略发布配置。

这可以帮助您避免合并过程中可能出现的错误以及合并所需的时间。

You say "most configurations are contained within the code itself" but hopefully all configuration is isolated in files specific to configuration. If that is the case, you could keep both test and release cases of the configuration code in the same branch. You could then use a command line switch to use the test config instead of the normal one.

If your program can read a configuration selection from the command line (or environment variable, registry key, text file or whatever), then you won't have to merge at all. The program can ignore the test configuration files when the command line switch is not present, and ignore the release configuration when the command line switch is present.

This saves you from the possible mistakes during the merge as well as the time it takes to do the merge.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文