查看远程分支
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
查看本地分支
$ git branch
* master
创建分支
$ git branch test
$ git branch
* master
test
把分支推到远程分支
$ git push origin test
Total 0 (delta 0), reused 0 (delta 0)
To https://git.xxx.xxx/xxx/xxx.git
* [new branch] test -> test
切换分支到test
$ git checkout test
Switched to branch 'test'
$ git branch
master
* test
删除本地分支
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
$ git branch -d test
Deleted branch test (was aaadfcd).
查看本地和远程分支
git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/test
在clone完成之后,Git 会自动为你将此远程仓库命名为origin(origin只相当于一个别名,运行git remote –v或者查看.git/config可以看到origin的含义),并下载其中所有的数据,建立一个指向它的master 分支的指针,我们用(远程仓库名)/(分支名) 这样的形式表示远程分支,所以origin/master指向的是一个remote branch(从那个branch我们clone数据到本地)
执行 git remote -v 的结果,看出来origin其实就是远程的git地址的一个别名。
$ git remote -v
origin https://xxx.xxx.xxx/xxx/xxx.git (fetch)
origin https://xxx.xxx.xxx/xxx/xxx.git (push)
删除远程版本
git push origin :test
To https://xxx.xxx.net/xxx/xxx.git
- [deleted] test
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master