因公司改用git服務(wù)器進行代碼版本控制单雾,所以原本在SVN服務(wù)器上的iOS項目需要遷移至git服務(wù)器赚哗。connerstone不適用了,sourcetree是一個比較好的選擇硅堆。在mac上使用git + sourcetree的方式管理代碼屿储,集成步驟如下:
一、生成與使用SSH Key
1.> SSH key提供了一種與Git服務(wù)器通信的方式渐逃,分為公鑰和私鑰通過這種方式够掠,能夠在不輸入密碼的情況下,將Git服務(wù)器作為自己的remote端服務(wù)器茄菊,進行版本控制
2.> 檢查SSH keys是否存在:
打開終端? cd ~/.ssh 能進去這個文件夾說明已經(jīng)存在祖屏,就前往該文件夾刪掉文件夾,重新創(chuàng)建
3.> .生成新的ssh key
在命令行中輸入 ssh-keygen -t rsa -C "your_email@xx.com"
默認會在相應(yīng)路徑下生成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ù)制公鑰內(nèi)容或者將這個文件發(fā)給后臺人員期丰,后臺人員去將公鑰添加至git服務(wù)器
三、使用source客戶端
使用source比起命令行更方便執(zhí)行pull吃挑、push钝荡、commit等操作,推薦使用舶衬。添加新的倉庫 --- 輸入提供的git地址即可開始了埠通。如果遇到如下錯誤,是權(quán)限的原因逛犹,聯(lián)系后臺人員:Unable to create temporary file: Permission denied
四端辱、參考閱讀
1. 如何生成SSH key
2. ?git教程
3. sourceTree 添加 ssh key 方法
4. Mac 下source tree 與 gitlab 添加 ssh 密鑰