git 克隆指定分支代码

git拉取代码最常用的方式为:

git clone http://gitslab.yiqing.com/declare/about.git

这种方式没有指定分支,当代码有多个分支时,拉取的分支不一定就是master。比如,下面这个其实拉下来的就不是master分支代码:

[root@izbp1845cet96se1qmb5ekz home]# git clone http://gitslab.yiqing.com/declare/about.git
Cloning into 'about'...
Username for 'http://gitslab.yiqing.com': account
Password for 'http://account@gitslab.yiqing.com': 
remote: Counting objects: 116, done.
remote: Compressing objects: 100% (86/86), done.
remote: Total 116 (delta 45), reused 80 (delta 28)
Receiving objects: 100% (116/116), 313.49 KiB | 508.00 KiB/s, done.
Resolving deltas: 100% (45/45), done.
[root@izbp1845cet96se1qmb5ekz home]# ls
about
[root@izbp1845cet96se1qmb5ekz home]# cd about/
[root@izbp1845cet96se1qmb5ekz about]# git branch
* develop

 

使用git拉代码时可以使用 -b 指定分支

指定拉 master 分支代码

git clone -b master http://gitslab.yiqing.com/declare/about.git

指定拉 develop 分支代码

git clone -b develop http://gitslab.yiqing.com/declare/about.git

 

查看当前项目拉的是哪个分支的代码:

进入项目根目录, 然后执行 git branch 命令

git branch

如图所示:

 

查看当前项目拉的是哪个分支的代码详情:

进入项目根目录, 然后执行 git branch -vv 命令

git branch -vv

如图:

 

查看分支上的递交情况:

进入项目根目录,执行 git show-branch

git show-branch

如图:

  • 47
    点赞
  • 132
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值