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栈