- 创建分支
git branch test 基于当前commit 创建test分支,.git/HEAD文件中记录了当前分支的名字
- 删除分支
git branch -d test 删除本地test分支
git branch -D test test分支还没有合入当前分支,所以要用-D参数才能删掉
git push origin --deleted test 删除远程test分支
git push origin:test 删除远程test分支
- 查看分支
git branch 列出当前分支清单
git branch -a 查看远程分支和本地分支
git branch -v 查看各个分支最后一个提交信息
git branch --merged 查看哪些分支以及合并入当前分支
- 拉取分支
git fetch origin 同步远程服务器的数据到本地
git checkout -b test origin/test_remote 将远程分支test_remote拉取下来到本地test分支
git checkout test 将远程分支test拉取下来到本地test分支
git pull test 从远程分支test中checkout下来的本地分支test成为跟踪分支,使用git pull或者git push 就会操作到对应的远程分支test