Http方式
這個沒什么好說的,直接clone http的地址(git地址分為ssh地址和http地址),只是每次同步(pull和push)都需要輸入賬號密碼
SSH 配置
1、設置Git的user name和email
git config --global user.name "Sunny"
git config --global user.email "sunny@woqugame.com"
2、生成密鑰
ssh-keygen -t rsa -C "sunny@woqugame.com"
連續(xù)三個回車,會生成兩個文件id_rsa
和 id_rsa.pub
在~/.ssh目錄下
Window默認在C:\Users\Administrator.ssh目錄下
3、添加密鑰到ssh-agent
為了確保 ssh-agent 是可用的。ssh-agent是一種控制用來保存公鑰身份驗證所使用的私鑰的程序,其實ssh-agent就是一個密鑰管理器,運行ssh-agent以后,使用ssh-add將私鑰交給ssh-agent保管,其他程序需要身份驗證的時候可以將驗證申請交給ssh-agent來完成整個認證過程。
eval $(ssh-agent)
添加生成的 SSH key 到 ssh-agent。
ssh-add ~/.ssh/id_rsa
4、登陸Gitlab,將
id_rsa.pub
里的內(nèi)容添加進去
大功告成!!!
TortoiseGit 工具
TortoiseGit 使用擴展名為ppk的密鑰,而不是ssh-keygen生成的rsa密鑰。也就是說使用ssh-keygen -C "username@email.com" -t rsa產(chǎn)生的密鑰在TortoiseGit中不能用。而基于git的開發(fā)必須要用到rsa密鑰,因此需要用到TortoiseGit的putty key generator工具來生成既適用于git的rsa密鑰也適用于TortoiseGit的ppk密鑰,配置步驟如下:
1、選擇剛才上次的私鑰文件id_rsa,然后”save private key“保存成ppk文件
2、然后用TortoiseGit clone代碼,load 剛剛生成的ppk文件,OK,如下圖
至此,就可以開心愉快的用TortoiseGit啦
參考:
http://blog.csdn.net/roxliu/article/details/31790985
http://rongjih.blog.163.com/blog/static/335744612010619111042465/