以GitHub為遠程倉庫
首先創(chuàng)建你的github賬號,
添加SSH?
生成SSH
1.打開終端
ssh-keygen -t rsa -C "youemail@eg.com"?
一直enter就可以
cd .ssh
ls
cat id_rsa.pub
紅色的部分就是SSH,復(fù)制到github的SSH中,添加上就可以
回到github主頁
start a project
將新創(chuàng)建的空倉庫git clone到你的桌面
git clone git@github.com:xxx/projectname
cd進入代碼倉庫
在代碼倉庫里創(chuàng)建.gitignore文件
.gitignore忽略文件
touch .gitignore
open .gitignore
里面放入
*.DS_Store
*UserInterfaceState.xcuserstate
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xcuserstate
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
# 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/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
# 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://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/
git add . / ?git add .gitignore?
git commit -m "add .gitignore"
git push?
到此.gitignore文件就添加到遠程的代碼倉庫了
常用到的git命令
git add .
git commit -m "注釋"
git branch 查看本地分支
git branch -a 查看遠程分支
git branch dev 創(chuàng)建一個名為"dev"的分支,ps:剛創(chuàng)建的分支只在本地,遠程分支里沒有
git checkout dev 切換到"dev"這個分支
git branch -r -d origin :dev ?(remotes/origin/dev)
git push origin :dev 兩句一起使用,刪除遠程分支
git push origin dev?
git pull origin dev
git push