加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xcode – 为什么git不会忽略这些文件?

发布时间:2020-12-15 01:46:48 所属栏目:百科 来源:网络整理
导读:我的.gitignore文件包含以下行: xcuserdata/**/* !xcuserdata/**/xcschemes/* 但仍会跟踪以下文件 /MyApp/MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist 为什么会这样?我该如何解决这个问题? PS:如果我有MyApp.xcode
我的.gitignore文件包含以下行:

xcuserdata/**/*
 !xcuserdata/**/xcschemes/*

但仍会跟踪以下文件
/MyApp/MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist

为什么会这样?我该如何解决这个问题?

PS:如果我有MyApp.xcodeproj / xcuserdata / colas.xcuserdatad / xcdebugger,则会忽略这些文件.但我不明白为什么没有这种“黑客”就不会忽视它们.

编辑1

与其中一个答案中的说法相反,即模式

xcuserdata/**/*
 !xcuserdata/**/xcschemes/*

工作!!!我的意思是,跟踪/ xcschemes下的文件.

另请参阅文章Git ignore file for Xcode projects,我在这里获得此.gitignore文件.

编辑2

我的Git版本是1.8.3.4(Apple Git-47).

编辑3

当我git check-ignore这个文件时,这就是我得到的

fatal: Not a git repository (or any of the parent directories): .git

但事实是父目录是一个git目录……

编辑4

当我git check-ignore –no-index – 这个文件时,这就是我得到的

[MT] PluginLoading: Required plug-in compatibility UUID 37B30044-3B14-46BA-ABAA-F01000C27B63 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XcodeSnippetsHelper.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2014-02-10 10:03:50.856 xcodebuild[1496:d07] XcodeColors: load (v10.1)
2014-02-10 10:03:50.859 xcodebuild[1496:d07] XcodeColors: pluginDidLoad:
fatal: Not a git repository (or any of the parent directories): .git

编辑4bis

从根文件夹:

>如果我不使用no-index选项,则没有回复git check-ignore.
>如果我使用no-index选项:我收到错误错误:未知选项’no-index’…

奇怪; – !

解决方法

首先,您可以执行 git check-ignore(git 1.8.3.3)以查看忽略您的文件的规则(假设它首先不在索引中)

第二,阅读“.gitignore exclude folder but include specific subfolder”:

It is not possible to re-include a file if a parent directory of that file is excluded. (*)
(*: unless certain conditions are met in git 2.8+,see below)
Git doesn’t list excluded directories for performance reasons,so any patterns on contained files have no effect,no matter where they are defined.

因此,无论如何都不会忽略xcschemes的文件.
你需要ignore parent folder per parent folder.
但更好的方法是仅忽略文件,然后排除文件夹:

xcuserdata/**
!xcuserdata/**/
!xcuserdata/**/xcschemes/**

记得:

在排除文件之前,您需要从gitignore规则中排除文件夹.

请注意,使用git 2.9.x / 2.10(2016年中期?),如果排除该文件的父目录,则可以重新包含文件if there is no wildcard in the path re-included.

Nguy?n Thái Ng?c Duy (pclouds)正在尝试添加此功能:

> commit 506d8f1 for git v2.7.0,在commit 76b620d git v2.8.0-rc0中恢复
> commit 5e57f9c git v2.8.0-rc0,…在commit 5cee3493 git 2.8.0-rc4中恢复(!).

然而:

The directory part in the re-include rules must be literal (i.e. no wildcards)

所以这无论如何都不会在这里奏效.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读