git學習與常用命令
一、建立本地倉庫(初始化)
git init
二、建立檔案、資料夾
1> touch a.txt(存在相容性問題,有可能建立失敗)
2>echo.>b.txt(推薦)
資料夾:mkdir perry(檔名)
三、檢視當前狀態(紅色未追蹤、綠色追蹤)
git status
四、把新建立的檔案新增到git跟蹤(新增追蹤後變為綠色)
git add a.txt
git add .(提交所有)
五、提交
git commit -m "提交資訊" -----暫存提交(引號內為提交資訊
git commit -a -m "提交資訊" ----不需要暫存直接提交(引號內為提交資訊)
git commit -am "提交資訊" ----不需要暫存直接提交(和第二個一樣,am直接寫)
六、使用者郵箱
git config --global user.email "[email protected]" (你的郵箱)
git config --global user.name "xiaoming" (你的暱稱)
七、檢視配置
git config -l
八、刪除全域性配置
git config --global --unset user.email(刪除郵箱)
git config --global --unset user.name(刪除暱稱)
or
git config --local--user.email "[email protected]" (你的郵箱)
git config --local--user.name"xiaoming" (你的郵箱)
九、提交中文/資料夾中文
git config --global core.quotepath false(資料夾名稱中文引起的亂碼)
set LANG=zh_CN.UTF-8(vim上方選單欄右鍵設定->環境,把這一段加進去,就可以直接輸入中文了)
十、編輯退出
十一、檢視提交的資訊
git log
十二、出不去的話按“q”即可出去
十三、刪除
git rm b.txt(rm就是remove)
git rm f(強制刪除)
git rm cache(刪除倉庫中的,保留工作目錄中的,即狀態變為新建未追蹤)
十四、移動檔案