Why doesn't Xcode create a .gitignore file?

git, xcode

Solution

I'm pretty sure that Xcode does not create a gitignore file on its own. So this is how I start a new project now.

- Create a new project in Xcode. Do not create a local git repo. The problem with getting Xcode to create the repo is that it performs an initial commit before a gitignore file is created. I prefer to add gitignore before the initial commit.

- Close the project.

- In Terminal, navigate to the directory containing the new project.

- `git init`

- `curl https://www.gitignore.io/api/xcode > .gitignore` There are lots of places to get gitignore files but this is super handy as shown on NSScreencast episode 156.

- `git add .` Be sure to include the dot, that adds everything.

- `git commit -m “Initial commit."`

- Open the project in Xcode and inspect the `Source Control` menu. If you select `History` you should see the initial commit.

Update:

`www.gitignore.io` now redirects to `www.toptal.com/developers/gitignore`

It's nice. You can specify keywords like xcode, cocoapods, etc.

Problem

I'm aware of how to create one and there are lots of posts of what should be in them for an Xcode project. This is a more basic question. - When creating a new Xcode project with the git option why doesn't Xcode create a default .gitignore file? Assume that I'm just working locally, I haven't created any remotes. - If I don't add a .gitignore myself does that mean that the files that are usually added to a .gitignore (like .DS_Store and *.xcuserdatad for example) are being managed by git? Is this bad? - Or is Xcode doing something behind the scenes to ignore those files?

Original source