git merge 应该忽略一个目录 [英] git merge should ignore one directory

查看:40
本文介绍了git merge 应该忽略一个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在名为报告的目录中有大量数据.在与另一个分支进行 git merge 时,我在报告目录下遇到很多文件冲突.我希望 git merge 忽略报告下的文件.

I have tons of data in directory called reports. While doing git merge with another branch I am getting lots of conflicts for files under reports directory. I would like git merge to ignore files under reports.

换句话说,我想要所有来自 master 报告的数据,而不是来自 lab branch 的数据.

In another words I would like all the data from reports from master and not from lab branch.

这可能吗?

这就是我现在正在做的事情.

This is what I am doing right now.

git checkout master
git merge lab

推荐答案

如果您需要对这些文件进行版本控制,但只保留 master 分支上的版本,则需要一个 合并驱动程序:见这里是一个 keepMine 脚本.

If you need those files versioned, but keeping only the version on master branch, you need a merge driver: see here for a keepMine script.

每次将 lab 合并到 master 时,report 目录中的所有文件都将保留其内容(master 上的版本).

Each time you will merge lab to master, all files within the report directory will keep their content (the one versioned on master).

这篇关于git merge 应该忽略一个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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