git 创建工程及使用
由于在github上托管私有未开源代码是要收费的,故在oschina上创建项目,没有账号的小伙伴可以先注册一个账号. http://git.oschina.net/
1.创建项目

2.填写项目信息

3.将git上的项目下载下来
由于配置ssh认证比较麻烦,故采用https认证

4.在桌面上创建个存储工程的文件夹(也可以自己选择放在其他目录下)

5.用终端打开桌面上的工程文件
cd 那桌面上的gitTest文件拖进来 回车

6.把工程clone下来
git clone 工程远程路径 (也就是第3步路径复制下,粘贴到这个地方) 回车

clone成功 如下

clone成功显示下面结果
7.添加.gitignore文件
把github的 .gitignore文件复制下来
a.在github上搜 .gitignore 并点击github/gitignore 进到详情里面

b.点击github/gitignore 进到详情里面 用command + F 搜 swift

搜索 找到Swift.gitignore 文件 点击文件进去

c.将里面的文件进行复制

d. 进到gitTest下的swiftTest目录
cd swiftTest/ 回车
touch .gitignore 回车

e. 打开.git目录下的 .gitignore文件(用文本编辑器打开) 并把从github上复制的.gitignore内容复制到里面并保存 (注意: .git 是隐藏文件 需打开隐藏文件才能看到)

f.在.gitignore文件中 需把 #pods前的#删掉(解注释),这样的话 提交工程时,就不会把cocoapods中的第三方上传到远程仓库 (可自己决定是否上传)

更改后如下

h.将.gitignore文件添加到暂缓区
git add . (是点) 回车
git commit -m"添加忽略文件" 回车

i.添加到远程仓库
git push 回车


查看远程仓库 可看到.gitignore已经添加上去了
8.在 gitTest / swiftTest目录下初始化项目
创建工程,并将工程的文件保存在 gitTest / swiftTest目录下
9.将工程commit到远程仓库

10 填写信息 并将 push to remote 勾选 (将代码push到远程master分支,可自定义到别的分支上)

11.点击提交 会弹出一个框 输入oschina的账号和密码 并点击OK

12.已成功上传
