标签:
git branch -r
origin/master
git branch
*master
注:以*开头指明现在所在的本地分支
git branch -a
*master
remotes/origin/master
4-1 创建本地分支
$ git branch test_1 $ git branch -a * master test_1 remotes/origin/master
注:创建本地分支时,默认是把所在的本地分支的东西拷贝给新建本地的分支。
4-2 把本地分支推送到远端作为远端分支
$ git push origin test_1 To git@****** * [new branch] test_1 -> test_1 $ git branch -a * master test_1 remotes/origin/master remotes/origin/test_1
注:git push origin test_1会把本地的test_1分支推送到远端,本地test_1分支和远端的对应关系是test_1-->test_1
如果本地根本没有分支test_9,推送的话会提示错误
$ git checkout test_1 Switched to branch ‘test_1‘
$ git branch -a master test_1 test_2 remotes/origin/master remotes/origin/test_1 remotes/origin/test_2 $ git branch -d test_2 Deleted branch test_2 (was c470057). $git branch -a master test_1 remotes/origin/master remotes/origin/test_1 remotes/origin/test_2
可以看到本地分支test_2删除了
$ git branch -a * master test_1 remotes/origin/master remotes/origin/test_1 remotes/origin/test_2 $ git push origin :test_2 To git@*********- [deleted] test_2 $ git branch -a * master test_1 remotes/origin/master remotes/origin/test_1
注:git push origin :*** 就是删除远程分支的意思,和刚才我删除本地无关。如下面,我留着本地test_1分支,只是删除了远端的分支test_1
$ git push origin :test_1 To git@******** - [deleted] test_1 $ git branch -a * master test_1 remotes/origin/master
标签:
原文地址:http://www.cnblogs.com/kaituorensheng/p/5721629.html