最新消息:

git 查看远程分支、本地分支、删除本地分支

git admin 4182浏览 0评论

1 查看远程分支

$ git branch -a
* br-2.1.2.2
master
remotes/origin/HEAD-> origin/master
remotes/origin/br-2.1.2.1
remotes/origin/br-2.1.2.2
remotes/origin/br-2.1.3
remotes/origin/master

2 查看本地分支

$ git branch
* br-2.1.2.2
master

3 创建分支

root@aikaiyuan-PC /f/ggg/root (br-2.1.2.2)
$ git branch test
$ git branch
* br-2.1.2.2
master
test

4 切换分支到test

root@aikaiyuan-PC /f/ggg/root (br-2.1.2.2)
$ git branch
* br-2.1.2.2
master
test
root@aikaiyuan-PC /f/ggg/root (br-2.1.2.2)
$ git checkout test
M root-server/src/main/java/com/taobao/root/server/service/cmd/GetCustomerTarCmd.java
M root-server/src/main/java/com/taobao/root/server/util/ServerUtil.java
Switched to branch 'test'
root@aikaiyuan-PC /f/ggg/root (test)
$ git branch
br-2.1.2.2
master
* test

 

5 删除本地分支   git branch -d xxxxx

$ git checkout br-2.1.2.2
M root-server/src/main/java/com/taobao/root/server/service/cmd/GetCustomerTarCmd.java
M root-server/src/main/java/com/taobao/root/server/util/ServerUtil.java
Switched to branch 'br-2.1.2.2'
root@aikaiyuan-PC /f/ggg/root (br-2.1.2.2)
$ git br
* br-2.1.2.2
master
test
root@aikaiyuan-PC /f/ggg/root (br-2.1.2.2)
$ git br -d test
Deleted branch test (was 17d28d9).
root@aikaiyuan-PC /f/ggg/root (br-2.1.2.2)
$ git br
* br-2.1.2.2
master

6 查看本地和远程分支  -a。前面带*号的代表你当前工作目录所处的分支

root@aikaiyuan-PC /f/ggg/root (test)
$ git branch -a
br-2.1.2.2
master
* test
remotes/origin/HEAD -> origin/master
remotes/origin/br-2.1.2.1
remotes/origin/br-2.1.2.2
remotes/origin/br-2.1.3
remotes/origin/master

转载请注明:爱开源 » git 查看远程分支、本地分支、删除本地分支

您必须 登录 才能发表评论!