Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | 51CTO学院 | CSDN程序员研修院 | OSChina 博客 | 腾讯云社区 | 阿里云栖社区 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏多维度架构

126.2. 分支管理

Manipulating branches

git-branch - List, create, or delete branches

126.2.1. 查看本地分支

$ git branch
* master
			

查看远程分支

			
git branch -a			
			
			

126.2.2. 创建分支

			
$ git branch development
$ git branch
* master
  development
			
			

机遇分支创建分支

			
$ git checkout -b feature develop
$ git push --set-upstream origin feature
			
			

126.2.3. 删除分支

$ git branch -d staging
Deleted branch staging.

$ git branch
* master
			

126.2.4. 切换分支

$ git branch
* master
  testing

$ git checkout testing
Switched to branch "testing"

$ git branch
  master
* testing
			

126.2.5. 重命名分支

			
neo@MacBook-Pro-Neo ~/workspace/api.netkiller.cn % git checkout test
neo@MacBook-Pro-Neo ~/workspace/api.netkiller.cn % git branch -m test testing
neo@MacBook-Pro-Neo ~/workspace/api.netkiller.cn % git push --delete origin test
neo@MacBook-Pro-Neo ~/workspace/api.netkiller.cn % git push origin testing
			
			

126.2.6. git-show-branch - Show branches and their commits

$ git-show-branch
! [master] add a new file
 * [mybranch] add a new file
--
+* [master] add a new file