git查看、创建、删除、本地、远程分⽀⽅法详解1. 查看远程分⽀
git branch -r
origin/master
2. 查看本地分⽀
git branch
*master
英语六级成绩多少分过注:以*开头指明现在所在的本地分⽀
英语短句
3. 查看本地分⽀和远程分⽀
git branch -a
*master
remotes/origin/master
4. 创建分⽀
*新建⼀个分⽀,但依然停留在当前分⽀no politics today
git branch [branch-name]
*新建⼀个分⽀,并切换到该分⽀上
git branch -b [branch-name]
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,推送的话会提⽰错误
5. 切换到分⽀
$ git checkout test_1
Switched to branch 'test_1'
6. 删除本地分⽀
$ 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
interestingremotes/origin/master
remotes/origin/test_1
remotes/origin/test_2
可以看到本地分⽀test_2删除了
7. 删除远程分⽀
复制代码
$ 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
lama
高仓健追捕* master
test_1
remotes/origin/master
更多关于git命令的使⽤⽅法与实例请查看下⾯的相关链接
>watch your back