从git-diff中排除文件 [英] Excluding files from git-diff

查看:538
本文介绍了从git-diff中排除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用git跟踪一个项目。在工作副本中有一些Xcode项目文件需要跟踪,但不希望在差异中看到,因为总是有很多我从未感兴趣的更改过的行。是否有一种简单的方法可以使 git-diff 跳过这些文件?我试图设置一个自定义的沉默diff工具:

 
$ cat .gitattributes
Project.xcodeproj / * diff = nodiff

$ cat〜/ .gitconfig
[diff'nodiff]
command = / bin / true

但是:

 
$ git diff
外部差异死亡,停在Project.xcodeproj / zoul.mode1v3。

我做错了什么?

解决方案

问题在于 / bin / true 会立即返回而不读取其输入。 git diff 因此很合理地认为它已经过早地死亡了。

你真正想要做的是取消设置diff属性,不要将其设置为伪造命令。在你的 .gitattributes 中试试这个:
$ b

  Project.xcodeproj / *  - diff 


I am tracking a project with git. There are some Xcode project files in the working copy that I want to keep tracking, but do not want to see in diffs, because there are always dozens of changed lines that I am never interested in. Is there a simple way to have git-diff skip these files? I’ve tried to set up a custom "silent" diff tool:

$ cat .gitattributes 
Project.xcodeproj/* diff=nodiff

$ cat ~/.gitconfig 
[diff "nodiff"]
    command = /bin/true

But:

$ git diff
external diff died, stopping at Project.xcodeproj/zoul.mode1v3.

What am I doing wrong?

解决方案

The problem is that /bin/true will return immediately without reading its input. git diff therefore thinks, quite reasonably, that it has died prematurely.

What you really want to do is to unset the diff attribute, not set it to a bogus command. Try this in your .gitattributes:

Project.xcodeproj/* -diff

这篇关于从git-diff中排除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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