问题描述
是否可以一直取消合并某些文件?
Is it possible to keep some file unmerged all the time?
我想要的是:
如果有两个分支(A)和(B),并且它们具有相同的文件.例如
If there are two branches (A) and (B), and they have the same file. For example,
在分支(A)中,文件"setup"具有以下内容:
In branch (A) the file "setup" has the following:
this is setup
in a branch A
在分支(B)中,文件"setup"具有以下内容:
In branch (B) the file "setup" has the following:
this is setup
in a branch B
这些分支没有未提交的文件(不同分支中相同文件的不同提交).
These branches don't have uncommitted files (Different commits for the same files in different branches).
目标是合并这些分支后不要触碰这些文件.
和对此不起作用.因为它们仅在合并时发生冲突时才起作用.(好吧,是的,如果我们合并这两个分支并且只工作一次,将会发生冲突.但是,如果我们将(A)合并为(B),然后将(B)合并为(A),则文件在两个分支)
The solutions in How to tell Git to always select my local version and Prevent merging a file from master with Git don't work for this. Because they work only when there's a conflict while merging them. (Well, yes there's going to be a conflict if we merge these two branches and it works for once. But if we merge (A) to (B), then (B) to (A), then the files become the same in both branches)
GIT有这种可能性吗?
Does GIT have this kind of possibilities?
推荐答案
不,由于git对待合并的方式,git中没有简单的方法可以做到这一点.
No, there is no easy way in git to do this, because of how git treats merges.
我可能是错的,但是看来您想防止配置文件被合并.是对的吗?因为有更好的/其他方法来处理配置文件.
I might be wrong, but it seems you want to keep config files from getting merged. Is that right? Because there are better / other ways to deal with config files.
此页面介绍了一些解决几种情况的解决方案.
This page explains some solutions how to deal with several situations.
摘要:
- 如果您可以修改程序,请让其他人覆盖未跟踪的配置文件
- 如果您无法修改程序,请不要跟踪配置文件本身,而要跟踪模板.
这篇关于Git:取消合并特定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!