git 分支 branch 操作

创建分支

git branch test: 基于当前commit创建test分支。.git/HEAD 文件中记录了当前分支名字。

删除分支

git branch -d test:删除本地test分支

git branch -D test: test分支还没有合入当前分支,所以要用-D参数才能删掉。

git push origin --delete 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

猜你喜欢

转载自www.cnblogs.com/horanly/p/10551324.html