Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- self
- Observer
- list
- escaping
- singleton
- array
- SWIFTUI
- viewlifecycle
- mvvm
- NotificationCenter
- error
- apns
- calendar
- 글또
- 회고
- IOS
- SWIFT
- http
- class
- segue
- 고차함수
- uikit
- Refresh
- ScrollView
- PushNotification
- struct
- Switch
- 화면전환
- Git
- protocol
Archives
- Today
- Total
seong_hye, the developer
Git) .gitignore 생성 및 적용 방법 본문
📘 .gitignore
Git을 사용하다 보면 계속 사용하지 않는 파일이 변경되었다고 git commit 하는 일이 생기곤 한다그럴 때 사용할 수 있는 iOS에서의 .gitignore에 대해 알아보자
🔹 gitignore 란?
Git에서 버전 관리에 포함하지 않을 파일이나 폴더를 지정할 수 있도록 해주는 매우 중요한 설정 텍스트 파일
개발 프로젝트에서 불필요한 파일, 민감한 정보, 빌드 산출물 등이 Git에 올라가지 않도록 막는 역할을 함
📁 파일명은 항상 .gitignore
🔹 생성 방법
Xcode에서 Git 사용을 선택했다고 .gitignore이 자동으로 생성되지 않습니다.
=> 직접 추가해야 합니다.
1. 터미널에서 직접 생성
touch .gitignore
이후 원하는 편집기를 열어 편집하거나
// 터미널의 경우
nano .gitignore
파일에서 cmd + shift + . 눌러 숨겨진 파일에서 .gitignore 파일 찾아 열기
2. GitHub에서 템플릿 가져오기
- https://github.com/github/gitignore 접속
- Swift.gitignore, macOS.gitignore, Xcode.gitignore 등 선택
- 내용 복사 -> .gitignore 파일에 붙여넣기
✅ 예시 내용
# macOS
.DS_Store
# Xcode
build/
DerivedData/
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcworkspace
xcuserdata/
*.xcuserstate
# SwiftPM
/.build/
/Packages/
# CocoaPods
Pods/
Podfile.lock
# Carthage
Carthage/
# Fastlane
fastlane/report.xml
fastlane/Preview.html
# Archives
*.xcarchive
# 환경 파일
.env
Secrets.plist
✅ 와일드 카드 사용법
문법 | 의미 | 예시 |
* | 모든 문자열 | *.log -> 모든 .log 파일 제외 |
? | 문자 1개 | file-?.txt -> file-a.txt, file-1.txt |
/ | 디렉토리 구분자 (절대 경로 의미) | /build/ -> 루트의 build 폴더 제외 |
! | 무시 예외 | !important.log -> 무시하지 않음 |
🔹 커밋에 반영
git add .gitignore
git commit -m "add) .gitignore"
⚠️ .gitignore에 추가만 해서는 이미 커밋된 파일은 무시되지 않음
✅ 해결 방안
git -rm --cached filename
//전체 정리의 경우
git rm -r --cached .
git add .
git commit -m "fix) Update .gitignore"
.gitignore의 경우 프로젝트 시작 전 미리 설정해두는 것이 가장 안전함
api 키나 토큰 등 민감 정보는 반드시 무시 대상에 포함시켜야 함
사용자 설정 파일, .xcuserdata, .vscode/,.idea/ 폴더 등도 무시하는 것이 좋음!
Comments