如何忽略git diff --no-index上的目录? [英] How to ignore directory on git diff --no-index?

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

问题描述

我正在尝试在同一存储库中的两个文件夹之间创建彩色差异(这可能是完全错误的方法).

I am trying to create a colorized diff between two folders in the same repository (This may be the totally wrong approach).

我相信一种实现方法是通过git diff --no-index folder1 folder2,它将自动为您创建一个补丁(很酷).

I believe one way of achieving this is through git diff --no-index folder1 folder2 and it will automatically create a patch for you (Cool).

但是,差异也包括(正如人们所期望的)所有.gitignore文件.

However, the diff also includes (as one might expect), all of the .gitignore'd files as well.

folder1
  node_modules
  src/
  .gitignore
  package.json
  README.md

folder2
  node_modules
  src/
  .gitignore
  package.json
  README.md

我想忽略node_modules.

可能吗?替代品?

推荐答案

您可以尝试使用assume-unchanged标志
https://git-scm.com/docs/git-update-index

You can try and use the assume-unchanged flag
https://git-scm.com/docs/git-update-index

指定此标志时,不会更新为路径记录的对象名称.
而是,此选项设置/取消设置路径的假定不变"位.

When this flag is specified, the object names recorded for the paths are not updated.
Instead, this option sets/unsets the "assume unchanged" bit for the paths.

当假定不变"位打开时,用户承诺不更改文件,并允许Git假定工作树文件与索引中记录的文件匹配.如果要更改工作树文件,则需要取消设置该位以告知Git.当在lstat(2)系统调用非常慢的文件系统(例如cifs)上处理大型项目时,这有时会很有帮助.

When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).

如果需要在索引中修改此文件,Git将失败(正常).合并提交时;因此,如果假定未跟踪的文件在上游进行了更改,则您将需要手动处理这种情况.

Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.

这篇关于如何忽略git diff --no-index上的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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