1

It seems that when you create a file with XCode for a project under git version control, it will always do a git add for the new file.

If you then commit, then the new file's in your repo's history for good.

I want to add this file to the XCode project, but not have it be tracked by git. So what I do now:

  • (XCode) Create the file in XCode
  • (Terminal) Create .gitignore for the project repo
  • (Terminal) add and commit .gitignore with the file's name in it
  • (Terminal) git rm --cached on the file which XCode added to git
  • (XCode) Verify that the file cannot be selected for a commit in the XCode commit window

I'd be happy to settle for a way to get XCode to optionally skip the git add for the new file so that I can skip git rm --cached. Also adding it to the .gitignore would be icing. Anyone know a way?

1 Answer 1

2

I want to add this file to the XCode project, but not have it be tracked by git.

To achieve this, you must uncheck the Add and remove files automatically under Xcode -> Preferences -> Source Control

enter image description here

I'd be happy to settle for a way to get XCode to optionally skip the git add

I'm afraid it's not possible to have it add and remove files optionally. It either yes for all files, or no for all files.

Sign up to request clarification or add additional context in comments.

2 Comments

Gets the ? rather than A next to the new file, though! Thanks!
It's because xcode can see there is a new file, but it's untracked

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.