[Swift5] How to create a .gitignore file and the code that should be written by default

What is .gitignore

In summary, .gitignore is a file that does not upload code to git (Github) that may cause problems if it is known to others such as APIKey.

It is treated as part of security.

How to create a .gitignore file

Move to the target project directory in the terminal and create a file with the following command

% touch .gitignore   

Open the created file with the following command

% open .gitignore     

Write the following code in the opened file

# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# CocoaPod
Pods/*

# others
*.swp
!.gitkeep
.DS_Store

Also, if you create .gitignore in the middle of development (if you have already committed to git), Set all files out of git once with the following command

 git rm -r --cached .

Next, set it as the target of git again

git add . 

By executing these two commands, the files registered in .gitignore will not be uploaded even during development.

However, I've never had a hard time creating a .gitignore file right after creating a project.

Remarks

As the default setting of Mac, files starting with . (Dot) can no longer be viewed, so even if you create a .gitignore file, it will not be displayed in Finder etc. (So ​​open from the terminal)

If you want to check it properly with Finder etc., please refer to How to show/hide hidden files in Finder on Mac.

Recommended Posts

[Swift5] How to create a .gitignore file and the code that should be written by default
How to create a jar file or war file using the jar command
[Swift5] How to create a splash screen
[Rails] How to create a table, add a column, and change the column type
How to create a convenient method that utilizes generics and functional interfaces
How to create a class that inherits class information
[Swift5] extension that allows UIImage to be specified by a String type URL
[ruby] How to assign a value to a hash by referring to the value and key of another hash
How to deploy VS Code Remote Containers in a docker-compose project that includes both the API and the front app
[Swift5] How to analyze complex JSON and get the index of the element that satisfies the condition
Create a jar file that can be executed in Gradle
How to create a form to select a date from the calendar
How to create a placeholder part to use in the IN clause
Add a shadow to the Swift Button (and also the circle)
How to create and launch a Dockerfile for Payara Micro
How to create a method
A collection of patterns that you want to be aware of so as not to complicate the code
How to make a key pair of ecdsa in a format that can be read by Java
Let's create a Docker container that can connect to CentOS 8 with the minimum configuration by SSH
I want to create a chat screen for the Swift chat app!
How to create a registration / update function where the table crosses
[Swift5] How to get an array and the complement of arrays
Create a static file that expands variables using the ERB class
How to load a Spring upload file and view its contents
How to read a file and treat it as standard input
How to open a script file from Ubuntu with VS code
How to identify the path that is easy to make a mistake
The operator that was born to be born, instanceof (Java) ~ How to use the instanceof operator ~
[chown] How to change the owner of a file or directory
[Swift5] How to communicate from ViewController to Model and pass a value
Create a calendar from the Calendar class by specifying the year and month
How to operate IGV using socket communication, and the story of making a Ruby Gem using that method
[Java] How to create a folder
[Swift] How to send a notification
How to return a value from Model to Controller using the [Swift5] protocol
How to quickly create a reverse proxy that supports HTTPS with Docker
The story of forgetting to close a file in Java and failing
How to run a GIF file from the Linux command line (Ubuntu)
[Java] Create a jar file with both compressed and uncompressed with the jar command
[Active Admin] I want to customize the default create and update processing
A memo that enabled VS Code + JUnit 5 to be used on Windows 10
[Docker] How to create a virtual environment for Rails and Nuxt.js apps
How to create a validator that allows only input to any one field
How to find out the Java version of a compiled class file
How to create a server executable JAR and WAR with Spring gradle
A story that was embarrassing to give anison file to the production environment
[swift5] How to change the color of TabBar or the color of item of TabBar with code
How to create your own annotation in Java and get the value
How to set tabs and spaces to be visible by using the tab key to insert spaces in Java files in Eclipse
Let's create a TODO application in Java 9 Create TODO display Sort by date and time + Set due date default to today's date
[Java] How to use the File class
Create a jar file with the command
How to delete the wrong migration file
How to delete the migration file NO FILE
How to call Swift 5.3 code from Objective-C
[Swift] How to implement the countdown function
How to find the tens and ones
[rails] How to create a partial template
How to create a route directly from the URL you want to specify + α
[Android] I want to create a ViewPager that can be used for tutorials
How to display today's date and time by default: Remove seconds or less