git使用
首先git是分佈式版本控制系統
git初始用
-
設置一個身份標識
-
$ git config --global user.name "Your Name"
-
$ git config --global user.email "[email protected]"
-
創建版本庫
- 選擇一個合適的位置創建一個空目錄
$ cd /e/git
$ mkdir learngit //創建一個倉庫
- 將倉庫變爲git可管理倉庫
git init
使用git
$ git add test.txt //告訴git 把文件添加到倉庫中
$ git commit -m "wrote a test file" //-m 後面是本次提交的說明
另外可以提交多個 然後一起使用commit命令
對接遠程倉庫 github
- 創建SSH KEy
$ ssh-keygen -t rsa -C "[email protected]"
然後在github中保存
- 添加一個遠程庫
- 進行連接
$ git remote add origin [email protected]:iszhonghu/springboot-testdemo.git
本地內容推送上去
$ git push -u origin master
推送步驟
echo “# springboot-testdemo” >> README.md
git init
git add README.md
git commit -m “first commit”
git remote add origin https://github.com/iszhonghu/springboot-testdemo.git
git push -u origin master
其他操作命令
git clone (地址) 下載
git status 查看是否還有的沒交的
git diff (查看改變了那個文件的什麼內容)
git log 查看日誌