Why are these files not ignored by git? - xcode

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":
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:
commit 506d8f1 for git v2.7.0, reverted in commit 76b620d git v2.8.0-rc0
commit 5e57f9c git v2.8.0-rc0,... reverted(!) in commit 5cee3493 git 2.8.0-rc4.
However:
The directory part in the re-include rules must be literal (i.e. no wildcards)
So that wouldn't have worked here anyway.

Adding file names to .gitignore helps prevent you from adding the files unintentionally.
If you do something like git add . to add a folder full of files to the repository, the files (or filetypes) ignored in .gitignore will not be added.
They would have to be added by using the -f flag with the git add command.
It will not change anything if the files are already tracked.
You can stop tracking the files by using the answer to the question:
Remove a file from a Git repository without deleting it from the local filesystem
edit: After rereading the question a few more times, I think you may be having roughly the same issue that was addressed in this answer:
.gitignore - ignore any 'bin' directory

Related

Why are subfolders not being seen by the Git repository?

I have just created a local repository (using Git) for a project that will contain many subfolders (it is a pedagogical project with Lesson 1...2...3 etc..., each one with a folder within the main directory).
I connected this to the remote repository I created on GitHub.com and hoped that would have been enough to start working, pushing, committing etc... now that I have created the first Xcode project inside the main folder neither Xcode Commit function nor Terminal git commit command is seeing any change.
The symptoms I see are that the remote repository sees "Project name" folder, then "Lesson 1" folder inside it but nothing else inside "Lesson 1", where the Xcode project should be (it actually is there in the Finder).
What may have gone wrong?
What would have been the proper set of actions to create a repository in a directory that would automatically fetch every new file added to it?
Thank you so much!
Git will not automatically track new files you create in the directory tree which contains your local git repo.
When you create new files, you need to inform git that you want them tracked, with the "git add" command.
git add path-to-new-file
If you create new files and do not add them, then when you run the "git status" command the output should contain a section labeled Untracked files, like this:
Untracked files:
(use "git add ..." to include in what will be
committed)
asdf.txt
It will show the path to the file(s) relative to the top of your git repo, including the filename(s). Pass all of that to the git add command. Then commit, just as you would for changed files.

Using git submodules as junctions in Windows

If a submodule's directory is a junction (Windows), git doesn't detect it as a repository and cannot work on such submodule.
For example, imagine a repository root is in c:\src\root, and that has one submodule subrepo, that is a junction to another drive. So c:\src\root\subrepo links to d:\submodules\subrepo.
If you try any git command on c:\src\root\subrepo you will receive an error message like
$ git pull
fatal: not a git repository: d:/submodules/subrepo/../.git/modules/subrepo
How can I solve these issues?
As you see, the problem is that git resolves the junction and works on the destination directory, instead of using the original path.
To solve the junction problem with git and submodules, it is enough to make a second junction, but in reverse way, to the .git directory of the parent rep. This should be a sibling of the subrepo directory, so it can be found when constructing the ../.git/ relative path.
d:\submodules\.git ==> c:\src\root\.git
c:\src\root\subrepo ==> d:\submodules\subrepo
Note that this may be a mess if you have different set of submodules, so in this case just group them into the same directory to avoid conflicts with duplicated .git directories.

How to enable .gitignore file in private repository in GitHub with GUI

I can't uploud a project in private repository even I'have .gitignore file(where I made a mistake, because .gitignore doesn't work). Message is that I have more than a hundred files, and simply I can't uploud it in one piece, just one by one folder or file.
I have make a new private repository in GitHub, and at the start of making it's offering to make a gitignore file, so I done that step(I chose a Visual Studio gitignore file, and then I put all files I don't need, even a whole folders I don't need from my project I've made in VS). But problem is in uplouding folders after I make the repository. Every time I try to uploud it, I get a message that I have more than a hundred files. I've even opened a whole new private repository in case git alredy tracked the files in this one. And it seems nothing is working. I have reed all official documentacion about gitignore files in GitHub, I've seen a bunch of Youtube tutorials and tryed to make a gitignore file direct in VS but also doesn't work.
Maybe it's seems funy to most of you and it is probably a banal mistake but I just can't figure this out.
SENCE I'M A TOTAL BEGINNER please can anyone tell me where I make a mistake?
Here is a piece of my .gitignore file, most of it is official code, and it is very big.
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
App_Data/
Content/
fonts/
Scripts/
*/favicon.ico
*/packages.config
I just want my whole project uploud it in one piece without unnecessary files from VS.
List item
I will augment #Harmonica141 answers by suggesting you to use on line .gitignore file generator.
After selecting desired IDE or programming language .gitignore file will be generated for you with all required regex and file exclusion.
After downloading a file you need to add it to the repository by command line.
Do as follows:
cd into/the/repository/folder
git add .gitignore
git commit -m "Added .gitignore."
git push origin
Your .gitignore is active as soon as it is tracked by git. To accomplish that, you will have to commit it. Do this first, make a commit consisting only of that file. Then git should not "see" all the files masked by it any longer.
In command line do as follows:
cd into the repository folder
git add .gitignore
git commit -m "Added .gitignore."
git status
The last statement should show you all the files that are still untracked or uncommitted but not the ones contained in the .gitignore. From there you can keep adding and committing as usual.
Don't forget to push later to have your changes up on remote.

how to gitignore a file without corrupting the master's gitignore file

I have a script I'm using from my repo's root and I don't want it to appear each time I git status.
I thought of adding it to .gitignore but I don't want this change tracked because I don't want the master's .gitignore to contain this file path (as no one else has it).
Is it possible to gitignore this file in a way my gitignore wouldn't be uploaded when, for example, I git commit -a?
You can use .git/info/exclude to have your non shared ignore rules.
See this SO answer When would you use .git/info/exclude instead of .gitignore to exclude files?
And the docu: https://git-scm.com/docs/gitignore
Create a .git/info/exclude file and put the file path there. The syntax is identical to .gitignore file, but the file local to your repo.

New files aren't showing up only folders

I'm relatively new to git. I'm using:
git version 1.8.1.msysgit.1
Powershell & Poshgit
I've added one new folder and one new file to my repository. When i do a git status i see the folder but not the file. Why?
In the untracked folder you see there is 1 .sql file and yes i'm sure its not in .gitignore (i've changed .sql files recently and they were tracked).
If i do a git add . will the file that is not shown be added?
Update:
I just had to add the directory and the file automatically shows up. I'm assuming if i had multiple files all of them whould show up. See the command i executed below:
git status is reporting that you have an entire directory without any files that you have git added. As soon as you git add one of the files inside the directory, it will list them.
That's a simplification of git. It knows that it doesn't track any file in that folder, so it just shows the folder name instead of all files it contains.

Resources