以GitHub为远程仓库
首先创建你的github账号,
添加SSH
生成SSH
1.打开终端
ssh-keygen -t rsa -C "youemail@eg.com"
一直enter就可以
cd .ssh
ls
cat id_rsa.pub
红色的部分就是SSH,复制到github的SSH中,添加上就可以
回到github主页
start a project
将新创建的空仓库git clone到你的桌面
git clone git@github.com:xxx/projectname
cd进入代码仓库
在代码仓库里创建.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 创建一个名为"dev"的分支,ps:刚创建的分支只在本地,远程分支里没有
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