1. 管理git ssh key
創建key pairs
ssh-keygen -t rsa -C "youremail@yourcompany.com"
~目錄下會生成.ssh目錄,包含id_rsa.pub和id_rsa兩個文件
添加private key
ssh-add ~/.ssh/id_rsa
如果出現錯誤,可以先使用如下命令
ssh-agent bash
在profile settings->SSH Keys->Add SSH Key中添加id_rsa.pub中內容
然后進行連接,
ssh -T git@gitlab.yourdoman
成功會顯示
Welcome to GitLab, xxx
如果出現提示SSL證書錯誤。如下
fatal: unable to access 'https://github.com/subying/jsbook.git/': SSL certificate problem: unable to get local issuer certificate
可以使用如下命令跳過SSL證書驗證
git config --global http.sslVerify false
2. git push內容
將目錄變成git管理的倉庫
get init
添加origin
git remote add origin git@gitlab.{your domain}.git
如果git上內容比本地新,pull內容到本地
git pull origin master
添加或更新本地內容到git
git add {your file}
git commit -m "your commit"
git push origin master
替換本地改動
git checkout -- <filename>