Reputation: 10378
What I'm doing:
I'm working in Xcode, and started using Git not that long ago.
As per normal, there are some files that I don't want to be included in the Git database, that are to do with Xcode settings. I have already been using a Git repository for a while, but now want to remove these 'editor' files as they are creating problems.
How I'm doing it:
The proper way to do this is apparently not to use a .gitignore. Rather, it is to use .git/info/exclude. By creating a new project in Xcode and selecting the "use Git" option, I was able to find out that the default setting for this should be a .git/info/exclude file of the following:
.DS_Store
UserInterface.xcuserstate
So I copied this exclude file over to the same git location for the project I'm working on, and it seems to be ok. Except...
What goes wrong:
The files of course will not be removed/untracked from my current project without manual intervention. So, I've tried the following, which doesn't work and tells me there are no such files:
git rm --cached .DS_Store
git rm --cached UserInterface.xcuserstate
But these files are definitely there, and if I go to commit my repo branch then all sorts of user interface files want to join the party too.
The Question:
So, what is the 'exclude' file actually doing? Is there a way to make the exclude file untrack or apply itself to all repo branches easily?
If not, how can I get my project into the same state that it would be had I created the git repo from Xcode at square one?
Upvotes: 3
Views: 4401
Reputation: 467051
One reason that the first git rm --cached
command you quoted would fail is that .DS_Store
is a directory. Try:
git rm -r --cached .DS_Store
... instead. You might also want to check with git ls-files
that there are actually files within that directory being tracked in the repository. If there weren't then that would also explain you getting an error. Check that you're getting case of those files exactly right as well.
(These are generally useful exclude rules that I would add to .gitignore
, incidentally.)
To answer your other question:
So, what is the 'exclude' file actually doing? Is there a way to make the exclude file untrack or apply itself to all repo branches easily?
If files are already being tracked in the repository, you will still need to manually unstage them, regardless of whether they're being ignored / excluded. Essentially, the various places you can add exclude rules all have the same syntax and semantics. The priority of those rules is also described in that documentation, but essentially:
.gitignore
files, starting from the current directory and going up to the top level..git/info/exclude
is used.core.excludesfile
.Upvotes: 2