如何防止git merge将特定文件从主干合并到分支中,反之亦然 [英] How to prevent git merge to merge a specific file from trunk into a branch and vice versa

查看:86
本文介绍了如何防止git merge将特定文件从主干合并到分支中,反之亦然的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发VHDL代码时正在使用git.我正在git分支中的组件comp_dev上进行开发.组件接口不会更改,仅组件内部的代码即可.现在,该组件已经存在于master分支中,但是以更稳定的版本存在,足以使其他开发人员能够使用该组件.其他开发人员也有他们的工作分支,并且当他们的代码很好时,他们会将其分支合并回master.

I am using git while developing VHDL code. I am doing development on a component in a git branch: comp_dev. The component interface does not change, just the code inside the component. Now, this component already exists in the master branch, but in a more stable version, enough for other developers to be able to use the component. The other developers also have branches for their work, and when their code is good they merge their branches back to master.

在这个阶段,我需要能够将所有更改从master合并回我的comp_dev分支,这基本上没有问题,但是有时我正在使用的组件的稳定版本会作为其他设计器的一部分进行更改工作,而不是界面.每当我想合并时,我都必须在该特定文件上执行手动git merge -s我们的操作,否则会出现冲突,需要手动解决,将其工作丢掉.

At this stage I need to be able to merge all the changes from master back to my comp_dev branch, which is basically no problem, but sometimes the stable version of the component I am working on do change as a part of other designers work, but not the interface. I have to do manual git merge -s ours on that particular file every time I want to merge, otherwise I get a conflict that I need to solve manually, throwing out their work.

如果我想将其他文件中的更改合并回master,也会发生同样的情况.如果我忘了做git merge -s我们的src/rx/state_machine.vhd comp_dev,然后再进行git merge,那么我要么以手动方式合并,要么意外地将不稳定版本的状态机合并到了src/rx/state_machine.vhd comp_dev.稳定的一个.

The same happens if I want to merge changes in other files back to master. If I forget to do git merge -s ours src/rx/state_machine.vhd comp_dev before I do a git merge, then I end up with either a manual merge, or I accidentally merge an unstable version of the state machine on top of the stable one.

是否有办法从合并中临时排除一个文件?

Is there a way to temporarily exclude one file from merges?

推荐答案

我发布了一个适用于我的解决方案

I posted a solution that works for me here

这篇关于如何防止git merge将特定文件从主干合并到分支中,反之亦然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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