gitattributes没有正确设置合并驱动程序 [英] gitattributes not setting merge driver correctly

查看:136
本文介绍了gitattributes没有正确设置合并驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下目录结构:

 项目/ 
.git /
...
app /
...
config /
初始化程序/
braintree.rb
环境/
production.rb
。 gitattributes

我的项目使用两个主分支,master和staging,每个跟踪一个不同的远程(生产和分段这个想法是,暂存分支随着新功能向前移动,它们被推送到暂存远程机器上并进行测试,然后主机被快速转发到匹配暂存并推送到生产远程。



下面是我想要做的:自由合并这两个分支,同时保留它们的版本 braintree.rb 和 production.rb 分开。



为了达到这个目的,在 .gitattributes 中(根据ProGit书籍):

  config / initializers / braintree.rb merge = our 
config / environments / production.rb merge = our

该文件存在于两个分支中。

我遇到的问题是这似乎对任何东西都没有影响。无论何时我在两者之间合并,文件无论如何都会发生变化,我必须再次改变它们。



我有一种感觉,我错过了一些非常明显的东西,但如此它远远地逃避我。我知道其他答案在这里涉及到创建自定义合并驱动程序,但ProGit书中没有提到这个过程,似乎暗示我们的驱动程序是内置的(和我已经看到它在手册页中提到,所以我相对确定它是)。我唯一能想到的另一件事是,我已经把 .gitattributes 放在了错误的地方或弄乱了它的内容,但是我找不到那些关于。我试过将它移动到与文件相同的目录,但无济于事。

如果有任何帮助,我在OS X上运行git 1.7.2版本。任何帮助都将不胜感激。

解决方案

有两个优秀的堆栈溢出响应解决了这个问题:




$如何告诉git始终选择我的本地版本来处理特定文件上的冲突合并? b $ b

.gitattributes&个人合并文件策略



我建议您阅读第一个链接中的顶部答案。它很长,但非常详细和信息丰富。


I have the following directory structure:

project/
    .git/
        ...
    app/
        ...
    config/
        initializers/
            braintree.rb
        environments/
            production.rb
    .gitattributes

My project uses two main branches, master and staging, each tracking a different remote (production and staging heroku apps).

The idea is that the staging branch moves forward with new features, they get pushed to and tested on the staging remote, then master is fast-forwarded to match staging and pushed to the production remote.

Here's what I want to do: freely merge these two branches while keeping their versions of braintree.rb and production.rb separate.

To accomplish this, here is what I put in .gitattributes (as per the ProGit book):

config/initializers/braintree.rb merge=ours
config/environments/production.rb merge=ours

The file is present in both branches.

The problem I'm encountering is that this doesn't seem to have any effect on anything. Whenever I merge between the two, the files get changed anyway and I have to go change them again.

I have a feeling I'm missing something horribly obvious, but so far it's escaping me. I know that other answers here have involved creating custom merge drivers, but the ProGit book makes no mention of this process and seems to imply that the ours driver is built in (and I've seen it mentioned in the man pages, so I'm relatively sure it is). The only other thing I can think of is that I've somehow put .gitattributes in the wrong place or messed up its contents, but I can't find much information on that. I've tried moving it to the same directory as the files, but to no avail.

In case it's of any help, I'm running git version 1.7.2 on OS X. Any help would be much appreciated.

解决方案

There are two excellent Stack Overflow responses which address this problem:

How do I tell git to always select my local version for conflicted merges on a specific file?

and

.gitattributes & individual merge strategy for a file

I'd suggest reading through the top answer in the first link. It's long, but very detailed and informative.

这篇关于gitattributes没有正确设置合并驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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