本文介绍了为什么这些文件不被git忽略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

但下列文件仍被追踪
/MyApp/MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist



为什么会这样? PS:如果我有 MyApp.xcodeproj / xcuserdata / colas.xcuserdatad / xcdebugger 如何解决这个问题?



,这些文件被忽略。但我不明白为什么它没有忽视这些黑客。






编辑1



与其中一个答案中的内容相反,该模式

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

作品!!!我的意思是,跟踪 / xcschemes 下的文件。

另请参阅,我得到这个 .gitignore 文件。

编辑2



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



编辑3



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

  fatal:不是git仓库(或任何父目录):.git 

但事实上,父目录是一个git目录...



编辑4



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

  [MT] PluginLoading:所需的插件兼容性UUID 37B30044-3B14-46BA-ABAA-F01000C27B63适用于路径'〜/ Library / Application Support / Developer / Shared / Xcode / Plug-ins / XcodeSnippetsHelper.xcplugin'不存在于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:
致命错误:不是gi (或任何父目录):.git



编辑4bis



如果我不使用<$ c
$ b

  • c> no-index 选项,没有回复 git check-ignore


  • 如果我使用 no-index 选项:我得到错误错误:未知选项'no-index'

    奇怪; - !

    (git 1.8.3.3+)查看哪些规则忽略了您的文件(假设它不在索引中首先)

    其次,阅读:

    因此, xcschemes 的文件不会被忽略。

    您需要。
    但更好的方法是仅忽略文件,然后排除该文件夹:

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

    请记住:

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




    请注意,使用git 2.9.x / 2.10(2016年中期?),如果该文件的父目录是排除。



    正试图添加此功能:


    • for git v2.7.0,还原为 git v2.8.0-rc0

    • git v2.8.0-rc0,...在 git 2.8.0-rc4。



    然而:

    所以这在这里不会有效。


    My .gitignore file contains these lines :

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

    But the following file is still tracked/MyApp/MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist

    Why is it so? How can I fix that?

    PS: If I had MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger, the files are ignored. But I don't understand why it does not ignore them without this "hack".


    EDIT 1

    Contrary to what is said in one of the answer, the pattern

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

    works !!! I mean, the files under /xcschemes are tracked.

    See also the post Git ignore file for Xcode projects, where I get this .gitignore file.

    EDIT 2

    My Git version is 1.8.3.4 (Apple Git-47).

    EDIT 3

    When I git check-ignore this file, here is what I get

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

    But the fact is that a parent directory is a git directory...

    EDIT 4

    When I git check-ignore --no-index -- this file, here is what I get

    [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
    

    EDIT 4bis

    From the root folder :

    • if I don't use the no-index option, there is no reply to git check-ignore.

    • if I use the no-index option: I get the error error: unknown option 'no-index'...

    Strange ;-!

    解决方案

    First, you can do a git check-ignore (git 1.8.3.3+) to see what rule is ignoring your file (assuming it wasn't in the index in the first place)

    Second, read ".gitignore exclude folder but include specific subfolder":

    So the file of xcschemes wouldn't be un-ignored anyway.
    You needed to ignore parent folder per parent folder.
    But a better approach is to ignores files only, and then exclude the folder:

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

    Remember:

    You need to exclude folders from the gitignore rules before being able to exclude files.


    Note that with git 2.9.x/2.10 (mid 2016?), it might be possible to re-include a file if a parent directory of that file is excluded if there is no wildcard in the path re-included.

    Nguyễn Thái Ngọc Duy (pclouds) is trying to add this feature:

    However:

    So that wouldn't have worked here anyway.

    这篇关于为什么这些文件不被git忽略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 08-13 05:47