git 克隆指定分支代码

501 阅读1分钟

git拉取代码最常用的方式为: git clone gitslab.yiqing.com/declare/abo… 这种方式没有指定分支,当代码有多个分支时,拉取的分支不一定就是master。比如,下面这个其实拉下来的就不是master分支代码:

[root@izbp1845cet96se1qmb5ekz home]# git clone gitslab.yiqing.com/declare/abo… Cloning into 'about'... Username for 'gitslab.yiqing.com': account Password for '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 gitslab.yiqing.com/declare/abo… 指定拉 develop 分支代码

git clone -b develop gitslab.yiqing.com/declare/abo…

查看当前项目拉的是哪个分支的代码: 进入项目根目录, 然后执行 git branch 命令

git branch

查看当前项目拉的是哪个分支的代码详情: 进入项目根目录, 然后执行 git branch -vv 命令

git branch -vv

查看分支上的递交情况: 进入项目根目录,执行 git show-branch

git show-branch