Skip to content

Instantly share code, notes, and snippets.

@andresr-dev
Last active April 24, 2024 19:57
Show Gist options
  • Save andresr-dev/cfa867c53ec1a551e1a38507c37cc99c to your computer and use it in GitHub Desktop.
Save andresr-dev/cfa867c53ec1a551e1a38507c37cc99c to your computer and use it in GitHub Desktop.
This is how you can create a .gitignore file in your Xcode projects in order to avoid problems with git
This is how to create a .gitignore file in the root file of our Xcode project, this is used to ignore saving certain files that are not necessary in our project, like the files that Xcode automatically generates after each build as DerivedData/ and build/. Saving these files causes unnecessary work and makes it harder to find the significant changes in our commit history. Here's the Terminal commands:
If this is the first time you are doing this, you are going to need to run this command, Important: This is a one-time-only command for each computer:
git config --global alias.ignore '!gi() { curl -L -s https://www.gitignore.io/api/$@ ;}; gi'
Now for each project, do this after creating the project:
1. cd -> drag the Xcode project file to terminal in order to get the path
2. git ignore swift,macos >.gitignore
3. git add .gitignore
4. git commit -m "Add .gitignore file"
If you want to see the .gitignore file go to your Xcode project file and press command+shift+. That will show your hidden files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment