Gitignore file for Swift Playground

Aim:

I would like to upload my Test.playground file to Github. Thought I would add a .gitignore file so that xcuserdata changes are not committed.

Question:

  1. What is preferred way to create a git file ? (I tried doing it through Xcode but it states that "All projects are already under source control.")
  2. Is .gitignore even recommended or am I missing the bigger picture ?

Note: When I create a git through command line as stated below and make any changes to the contents.xcplayground (main page) and save the .gitignore file gets deleted.

Attempt made so far:

cd Test.playground
git init
<create a .gitignore file>

Contents of my .gitignore file:

playground.xcworkspace/xcuserdata/

You probably want the Test.playground directory inside the Git repository. (Right now the Git repository is inside the playground.) Otherwise it won’t necessarily have the right extension anymore once you’ve cloned it elsewhere.

At that point, the .gitignore can go in the repository root, beside Test.playground. Then, being outside the playground, Xcode won’t touch it.

1 Like

@SDGGiesbrecht Works like a charm !! thanks a lot, was breaking my head over it.

Terms of Service

Privacy Policy

Cookie Policy