一、安装git
先Homebrew安装
1.Homebrew的安装非常简单,打开终端复制、粘贴以下命令,回车,搞定(请放心使用,原汁原味的官方安装方法搬运)
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2.安装完之后,
brew install git
3.检测是否安装成功
which git
应该得到 /usr/local/bin/git。如果正确,就说明已经成功从源代码安装 Git!
二、设置SSH
github使用SSH链接,需要设置SSH
1.检查SSH key
cd ~/.ssh
2.备份已有的key,(如果有的话)
mkdir key_backup
mv id_rsa* key_backup
3.生成SSH key
ssh-keygen -t rsa -C "changjian01@58ganji.com”
cat ~/.ssh/id_rsa.pub
将上面的的邮箱换成自己的邮箱,然后会如下显示 ,一路点确定...
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/changjian/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in yes.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
fb:c4:b0:e0:47:fd:be:e0:fb:ea:73:ef:a8:29:d5:22 jiang.bo.hit@gmail.com
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| |
| . |
| . S .. |
| . oE=o.. |
| . +o+.. |
| ..+.+.. |
| oOB=+o |
+————————+
如果出现上面的信息再输入
pbcopy < ~/.ssh/id_rsa.pub
4.将SSH key添加到GitHub
登录到GitHub页面,Account Settings->SSH Public Keys->Add another key
用下面的命令显示key
cat ~/.ssh/id_rsa.pub
将生成的key(id_rsa.pub文件)内容copy到输入框中,save。
然后就可以clone代码了,下载免费的工具sourceTree
git 初始化代码仓库:
下面的$project_root代表工程根目录
进入工程目录 cd $project_root
初始化git仓库 git init
添加文件到仓库 git add . (add后面有一个空格)
提交代码到仓库 git commit -m 'init commit'
链接到git server git remote add origin git@example.com:namespace/projectname.git
push代码到服务器 git push origin master
cocoaPods 安装命令
sudo gem install -n /usr/local/bin cocoapods
cocoaPods 更新卡住
pod install --verbose --no-repo-update