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

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

问题描述

作为如何设置一个git驱动忽略合并文件夹是,它没有回答原来的问题,仍然有我难倒。



不像与上面相关的问题,我有两个分支具有相同的目录集,并将其中一个合并到另一个我需要git完全忽略一个目录。



我试过了使用我自己的合并驱动程序,如我该如何告诉git总是选择我的本地版本来处理特定文件上的冲突合并?,但是这种方法的问题在于,只有在那里是这两个分支中的实际冲突文件。只要文件的更改只在一个分支上,git就会合并它们而不调用我的合并驱动程序。



这导致我不想要的目录中的文件发生更改。任何想法如何让git忽略该目录中的每个文件 - 无论它是否被触及? 解决方案

我实际上并没有使用Git,但我认为这适用于你的情况:



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

  git checkout master 
git merge --no-commit --no-ff development
git reset - / path / to / folder#从路径
恢复更新git commit

再说一遍,我不使用git,我只是根据我的经验推迟我的想法使用TryGit。


  1. 结账大师
  2. 合并但不提交,不快进。

  3. 合并现在处于暂存状态,因此重置整个目录树

  4. commit


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.

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.

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.

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?

解决方案

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

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

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

  1. checkout master
  2. merge, but don't commit, no fast forward.
  3. merges are now staged, so reset that entire directory tree
  4. commit

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

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