git基本使用
本文件以gitHub为例。
创建项目
1.登录github账号,点击右上角 + 号,选择 New repository.

填写 repository 名称,并点击 Create repository


2.创建本地项目,通过Xcode创建项目。
不多说了,作为ios开发者都会创建。
配置SSH
ssh是用于git(这里是github)认证用户是信息用的。SSH是一种基于RSA非对称加密的认证方式。
1.打开github网站 https://help.github.com,可以查看如何配置ssh

如果你已有另外的git配置ssh,可以查看这里,配置多个ssh,点击下面红框的位置:https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

配置ssh的命令:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
这里的邮箱地址需要,应该写上你git 的邮箱地址。ssh存储的默认路径是下面的红框的位置(我这里已存在其他ssh,就重新制定了路径)
注意:建议不要输入密码,不然每次使用git命令的时候总是提示你输入密码

执行 cd ~/.ssh , 进行pbcopy < id_dsa.pub ,复制ssh,,我这里复制的是id_dsa
.pub下的公钥。要根据你的存储的文件名来进行复制。
或者
前往文件夹 /User/你的电脑名称/.ssh,用 文本编辑 软件打开并赋值,黏贴账号的ssh设置位置:

连接远端库与本地项目
1. 打开终端,cd到项目目录下,执行一下命令:
git init
git remote add origin git@github.com:seriousCook/cookTest.git (远端git库地址)
git add . (添加文件," . "指的是所有的文件)
git commit -m "上传文件的描述备注"
git push -u origin master (master值的远端的其中一个分支branch,也可以改为其他的,如: 1.0.0)
稍稍等待即可。
到项目地址刷新页面就可以看到上传的文件。
使用SourceTree版本管理
本地已有项目
如下如图选择,找到项目打开即可

远端下载项目

填写以下信息,点击克隆:

双击项目列,打开如图:

更新,提交代码:

提交
