Git - 在合并期间忽略文件 [英] Git - Ignore files during merge

查看:46
本文介绍了Git - 在合并期间忽略文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在远程 beanstalk 服务器上有一个名为 myrepo 的存储库.

I have a repo called myrepo on the remote beanstalk server.

我将它克隆到我的本地机器上.创建了两个额外的分支:stagingdev.也将这些分支推送到远程.

I cloned it to my local machine. Created two additional branches: staging and dev. Pushed these branches to remote as well.

现在:

 local                   remote                   server
 --------------------------------------------------------  
 master  ==> Pushes to  `master`  ==> deployed to `prod`
 staging ==> Pushes to  `staging` ==> deployed to `staging`
 dev     ==> Pushes to  `dev`     ==> deployed to `dev`

我有一个名为 config.xml 的文件,它在每个分支上都不同.

I have a file called config.xml which is different on each branch.

我只想在合并期间忽略此文件.但是我希望在我结帐或从/提交到 repo 分支时包含它.

I want to ignore this file only during merges. But I want this to be included when I checkout or commit from / to the repo branch.

我想要这个的原因是,我们有一个部署脚本,可以拉取(签出)特定分支并部署在相应的服务器上.所以我们需要该特定分支的 config.xml 文件在部署时进入特定的服务器,如上所示.

The reason I want this is, we have a deploy script that pulls (checkout) the specific branch and deploys on the respective servers. So we need config.xml file of that specific branch go into the specific server as indicated above when deployed.

我猜 .gitignore 不会工作.其他选项是什么?请注意,被忽略的文件应该是 checkout 和 commit 的一部分,这很重要.它应该只在合并期间被忽略.

I guess .gitignore wont work. What are the other options? Note that the ignored file should be part of checkout and commit, which is important. it should be ignored only during merges.

谢谢!

推荐答案

我最终找到了 git attributes.正在尝试.工作至今.还没有检查所有场景.但它应该是解决方案.

I ended up finding git attributes. Trying it. Working so far. Did not check all scenarios yet. But it should be the solution.

合并策略 - Git 属性

这篇关于Git - 在合并期间忽略文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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