test-branch——分支名
1.查看分支
$ git branch //查看当前分支
$ git branch -a // 查看所有分支
$ git branch -r //查看远程分支
2.创建分支
$ git checkout -b test-branch
3.切换分支
$ git checkout test-branch
4.推送本地分支到远程分支
$ git push origin test-branch:test-branch
5.本地分支与远程分支建立关联
$ git branch --set-upstream-to=origin/test-branch
6.删除分支:
$ git branch -d test-branch //删除本地分支(未进行关联)
$ git branch -D test-branch //删除本地分支(已进行关联)
$ git push origin :test-branch或 git push origin -d test-branch//删除远程分支
7.更新分支代码并提交
$ git add .
$ git commit -m "备注"
$ git push origin test-branch //如果切换到那个分支中,直接使用git push即可
8.合并分支
$ git merge origin test-branch
9.查看状态
git status //查看当前状态
git reset HEAD //撤销上一次add
git reset HEAD XXX.html //撤销上一次add的某个文件
10.拉取
git clone '代码库地址'
11.强制拉取
git fetch --all
git reset --hard master
git pull #可省略
12.删除git
rm -rf .git
13.添加新仓库
git init
git remote add 库名 代码库地址
git pull 库名 分支名
14.仓库、分支详情
vim .git/config