- 下載安裝Git
從Git 官方網站下載你須要的版本的git。 安裝git,推薦選擇默認安裝。
- 配置Git
安裝完成後,進入命令行,輸入git 你會看到以下圖所示:![](http://static.javashuo.com/static/loading.gif)
看到上圖說明您已經成功裝入Git,這個時候你須要登陸到咱們的 Git服務器。 點擊右上角的小頭像,以後點擊ssh-keys如圖所示:
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
若是你是第一次使用git,這時候你須要到你的用戶目錄下找到一個叫作.ssh 的文件夾,若是你是windows用戶打開Git Gui,選擇show SSH Key:
![](http://static.javashuo.com/static/loading.gif)
若是沒有生成過須要點擊Generate Key
![](http://static.javashuo.com/static/loading.gif)
而後將生成的內容拷貝到網頁 SSH keys 的文本框內。如今你應該能夠克隆代碼了。
- 克隆代碼
選擇一個項目,點擊複製按鈕
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
選擇你要克隆的代碼的位置,輸入下面的命令:
git clone git@git.baokeyunguanjia.com:misc/bky-platform.git
- 建立分支和代碼提交
git add c.java
git status
git commit c.java -m '新增c類XXXXX'
git status
這個時候執行
git push
若是你是本地建立的分支會顯示
![](http://static.javashuo.com/static/loading.gif)
根據命令提示
git push --set-upstream origin test1
如圖中的url所示,若是你的代碼已經完成,能夠建立一個merge request 發佈到測試分支給測試驗證,若是沒有開發完成那就繼續開發。至此git的基本用法已經所有講完。若是你想要跟深刻的瞭解git。官方文檔仍是一個不錯的選擇。固然你也能夠在你本身的名下建立一個測試項目本身嘗試,每個人都能建立10個私有項目。