1. 程式人生 > 實用技巧 >git bash常用命令

git bash常用命令

常用操作

1、 git status 檢視倉庫狀態  
2、 git add 檔名 把檔案新增到倉庫
3、 git commit -m 把檔案提交到倉庫 -m後跟說明
4、 git add -A 提交當前目錄下多個檔案

5、 git rm 檔名 刪除版本庫檔案
6、 git rm --cached 檔名 刪除暫存區檔案,工作區檔案還在

7、 git remote -v     檢視詳細地址
8、 git diff 檔名     檢視修改的內容
9、 git log --pretty=oneline 檢視日誌
10、git reset --hard 版本號 穿梭版本
11、git config --system --list 檢視系統config

12、git config --global --list 檢視當前使用者(global)配置
13、git config --global user.name '' 檢視當前使用者名稱字
14、git config --global user.email '' 檢視當前使用者郵箱
15、git config --global user.name '' "xxxx" 修改當前使用者名稱字

15、git config --global user.email '' "[email protected]" 修改當前使用者郵箱

分支操作

1、git branch 檢視分支
2、git branch 名字 建立分支

3、git checkout 名字 切換分支
4、git merge 名字 合併分支(切換到主幹上合併分支)
5、git branch -d <name> 刪除分支
6、git checkout -b <name>或者git switch -c <name> 建立+切換分支
7、git switch 分支名切換已有分支

8、git switch -c dev 建立並切換到新的dev分支


遠端操作
1、git remote 檢視遠端倉庫
2、git remote -v 檢視倉庫地址
3、git remote remove <遠端庫名> 刪除遠端倉庫
4、git remote rename <舊名稱> <新名稱> 修改遠端倉庫名稱

5、git pull origin master 拉程式碼
6、git remote rm 遠端庫名 刪除指定的遠端庫

7、git remote add origin 新增遠端倉庫

8、git clone 從遠端倉庫克隆專案