因公司改用git服務器進行代碼版本控制,所以原本在SVN服務器上的iOS項目需要遷移至git服務器。connerstone不適用了,sourcetree是一個比較好的選擇。在mac上使用git + sourcetree的方式管理代碼,集成步驟如下:
一、生成與使用SSH Key
1.> SSH key提供了一種與Git服務器通信的方式,分為公鑰和私鑰通過這種方式,能夠在不輸入密碼的情況下,將Git服務器作為自己的remote端服務器,進行版本控制
2.> 檢查SSH keys是否存在:
打開終端? cd ~/.ssh 能進去這個文件夾說明已經存在,就前往該文件夾刪掉文件夾,重新創(chuàng)建
3.> .生成新的ssh key
在命令行中輸入 ssh-keygen -t rsa -C "your_email@xx.com"
默認會在相應路徑下生成id_rsa (私鑰)、id_rsa.pub(公鑰)兩個文件,按enter鍵
ssh-keygen -t rsa -C "your_email@example.com"
Generating public/private rsa key pair.
Enter file in which to save the key (~/.ssh/id_rsa):
4.> 輸入passphrase
可以不輸入密碼,直接按enter
Your identification has been saved in ~/.ssh/id_rsa.
Your public key has been saved in ~/.ssh/id_rsa.pub.
The key fingerprint is:
xxxxxxxxxxxxxxxxxxxxxxxx your_email@xx.com
The key's randomart image is:
xxx
5.> 添加私鑰
輸入命令行: ssh-add id_rsa?
二、將ssh key添加到GitHub中
執(zhí)行命令: cat ~/.ssh/id_rsa.pub 復制公鑰內容或者將這個文件發(fā)給后臺人員,后臺人員去將公鑰添加至git服務器
三、使用source客戶端
使用source比起命令行更方便執(zhí)行pull、push、commit等操作,推薦使用。添加新的倉庫 --- 輸入提供的git地址即可開始了。如果遇到如下錯誤,是權限的原因,聯(lián)系后臺人員:Unable to create temporary file: Permission denied
四、參考閱讀
1. 如何生成SSH key
2. ?git教程
3. sourceTree 添加 ssh key 方法
4. Mac 下source tree 與 gitlab 添加 ssh 密鑰