如何让git在合并时忽略目录 [英] How to make git ignore a directory while merging

查看:41
本文介绍了如何让git在合并时忽略目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置 git 驱动程序以忽略合并时的文件夹 是,它没有回答仍然让我难住的原始问题.

As interesting and useful as the answer to How to setup a git driver to ignore a folder on merge was, it did not answer the original question which still has me stumped.

与上面链接的问题不同,我有两个具有相同目录集的分支,为了将一个分支合并到另一个分支中,我需要 git 完全忽略一个目录.

Unlike the question linked to above, I have two branches with the same set of directories and for merging one into the other I need git to ignore one directory completely.

我如何告诉 git 总是为特定文件上的冲突合并选择我的本地版本? 但这种方法的问题在于仅当这两个分支中存在实际冲突文件时才会调用驱动程序.每当文件的更改仅在一个分支上时,git 会合并它们而不调用我的合并驱动程序.

I tried it with my own merge driver as described in How do I tell git to always select my local version for conflicted merges on a specific file? but the problem with this approach is that this driver is only invoked when there is an actual conflicting file in these two branches. Whenever the changes of a file are only on one branch, git merges them without calling my merge driver.

这会导致我不想要的目录中的文件发生更改.知道如何让 git 一直忽略该目录中的每个文件 - 无论它是否被触及?

This leads to changes in files in the directory that I do not want. Any idea how I could make git ignore each and every file in that directory all the time - whether it was touched or not?

推荐答案

我实际上并不使用 Git,但我认为这适用于您的情况:

I don't actually use Git, but I think this would work for your case:

使用类似于此处指定的内容:https://gist.github.com/564416>

Use something like what's specified here: https://gist.github.com/564416

git checkout master    
git merge --no-commit --no-ff development
git reset -- /path/to/folder # revert updates from path
git commit

再说一次,我不使用 git,我只是根据我使用 TryGit 的经验来考虑我认为事情是如何工作的.

Again, I don't use git, I am just deferring to how I think things work based on my experience with TryGit.

  1. 收银员
  2. 合并,但不要提交,不能快进.
  3. 合并现在已暂存,因此请重置整个目录树
  4. 提交

这篇关于如何让git在合并时忽略目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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