1、查看分支狀態
git branch 查看當前分支
git status 查看分支當前狀態(是否有待提交記錄)
2、修改並提交代碼**
git fetch --all
git add .
git commit -m "提交註釋"
git push origin 當前分支名
3、切換分支
git fetch --all
git pull
git checkout 新分支名
4、合併代碼
git fetch --all
git merge 分支名(不需要單獨commit) / git merge --no-ff 分支名(查看更改文件後需要commit)
git push origin 當前分支名
5、將test分支重置爲master
git fetch --all
git reset --hard origin/master
git push origin 當前分支名
6、回退代碼到某個版本**
git log
git reset --hard 版本id
git push origin 當前分支名
7、備份當前工作區內容
git stash(使用checkout切換分支時,如果不想提交修改代碼,可以先用此命令)
git stash pop 從Git棧中讀取最近一次保存的內容
git stash list 顯示Git棧內的所有備份
git stash clear 清空Git棧