git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支

本文转自:http://blog.csdn.net/arkblue/article/details/9568249
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 查看本地分支

shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git branch
* br-2.1.2.2
  master

3 创建分支

shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git branch test

shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git branch
* br-2.1.2.2
  master
  test

线面是把分支推到远程分支

$ git push origin test

4 切换分支到test

shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git branch
* br-2.1.2.2
  master
  test

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

shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (test)
$ git branch
  br-2.1.2.2
  master
* test

M 表示cong 原来分支(上一次修改没有提交br-2.1.2.2)带过来的修改
5 删除本地分支 git branch -d xxxxx

shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (test)

$ git checkout br-2.1.2.2
M       jingwei-server/src/main/java/com/taobao/jingwei/server/service/cmd/GetCustomerTarCmd.java
M       jingwei-server/src/main/java/com/taobao/jingwei/server/util/ServerUtil.java
Switched to branch 'br-2.1.2.2'

shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git br
* br-2.1.2.2
  master
  test

shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git br -d test
Deleted branch test (was 17d28d9).

shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git br
* br-2.1.2.2
  master

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

remotes/origin/HEAD -> origin/master #啥意思呢?

”在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  git@gitlab.alibaba-inc.com:middleware/jingwei.git (fetch)
origin  git@gitlab.alibaba-inc.com:middleware/jingwei.git (push)
shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (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

7 删除远程版本

git push origin :br-1.0.0

同步本地远程分支:
1 $: git fetch origin

4.提交分支数据到远程服务器:

1   $: git push origin <local_branch_name>:<remote_branch_name>

例如:

1   $: git push origin develop:develop

当然如果当前在develop分支下,也可以直接

1   $: git push
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值