Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
724 views
in Technique[技术] by (71.8m points)

xcode - Why are these files not ignored by git?

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 ;-!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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":

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.

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:

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

So that wouldn't have worked here anyway.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...