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

11.2. 分支管理

Manipulating branches

git-branch - List, create, or delete branches

11.2.1. 查看本地分支
$ git branch
* master
			

查看远程分支

			
git branch -a			
			
			
11.2.2. 创建分支
$ git branch development
$ git branch
* master
  development
			
11.2.3. 删除分支
$ git branch -d staging
Deleted branch staging.

$ git branch
* master
			
11.2.4. 切换分支
$ git branch
* master
  testing

$ git checkout testing
Switched to branch "testing"

$ git branch
  master
* testing
			
11.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
			
			
11.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