[Github] 로컬 프로젝트 폴더와 GitHub Rpository 연동하기
Updated:
Intro
Xcode로 생성한 iOS 프로젝트 폴더들을 Github Repository와 연동하고 PUSH 해봅시다.
New Repository 생성
먼저 Github 홈페이지에서 Repository를 생성해줍니다.
Repository Clone 하기
먼저 터미널에서 클론 받을 디렉토리로 이동합니다.
생성된 Repository를 Clone하여 줍니다.
Repository Clone 후 Pull
git clone https://github.com/Hyeonjiwon/iOS_Programming_Study.git
git init
git pull origin main
원래 git pull origin master을 입력하였는데
fatal: couldn't find remote ref master
위와 같은 오류가 발생해서 검색해 보니 Github의 기본 생성 branch 이름이 master에서 main으로 바뀌어서 난 오류였다.
테스트로 txt 파일을 만들어서 push 하려고 하니 또 아래와 같은 오류가 났다.
error: src refspec master does not match any
해당 에러 또한 위와 같은 이유로 발생하는 것이였다.
git branch -M main
git commit -m "commit message"
git push -u origin main
으로 하니 잘 푸쉬되었다,,,!
ignore 파일 생성하기
https://gitignore.io에서 Swift와 Xcode를 키워드로 검색해줍니다.
# Created by https://www.toptal.com/developers/gitignore/api/swift,xcode
# Edit at https://www.toptal.com/developers/gitignore?templates=swift,xcode
### Swift ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## User settings
xcuserdata/
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
## Obj-C/Swift specific
*.hmap
## App packaging
*.ipa
*.dSYM.zip
*.dSYM
## Playgrounds
timeline.xctimeline
playground.xcworkspace
# Swift Package Manager
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm
.build/
# CocoaPods
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
# Pods/
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace
# Carthage
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build/
# Accio dependency management
Dependencies/
.accio/
# fastlane
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
# Code Injection
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/
### Xcode ###
# Xcode
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Gcc Patch
/*.gcno
### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
**/xcshareddata/WorkspaceSettings.xcsettings
# End of https://www.toptal.com/developers/gitignore/api/swift,xcode
위 내용을 복사하여 terminal에서 git repository 디렉토리로 이동하여 아래 명령어를 입력하고 붙여넣어 줍니다.
vi .gitignore
내용 복붙
:wq
그 후 add > commit > push 를 해주면 완료입니다!
<img width=”794” alt=”0_4” src=”https://user-images.
Leave a comment