Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Xcode create a .gitignore file?

Tags:

git

xcode

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?
like image 746
Murray Sagal Avatar asked Sep 17 '25 22:09

Murray Sagal


1 Answers

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.

  1. 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.
  2. Close the project.
  3. In Terminal, navigate to the directory containing the new project.
  4. git init
  5. 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.
  6. git add . Be sure to include the dot, that adds everything.
  7. git commit -m “Initial commit."
  8. 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.

like image 85
Murray Sagal Avatar answered Sep 19 '25 13:09

Murray Sagal