美文网首页GIT
git clone --depth -b 选择性拉仓库

git clone --depth -b 选择性拉仓库

作者: 佐伊Joey | 来源:发表于2022-11-15 19:54 被阅读0次

拉仓库命令

对于大工程,上百条分支,上万条提交记录,全部git clone下来耗费带宽、硬盘太多,可以指定分支和最新提交,达到快速拉仓库的目的。命令格式:
git clone --depth 1 -b [分支名] [git仓库地址]

栗子:

  git clone --depth 1 -b dev ssh://www.tangtang.com:8235/iOS

切换分支

由于指定了特定分支拉代码下来,用git branch -r命令只能看到这条分支,不能切换到其他分支,怎么办?
解决方法也是有的。

修改git/config

在仓库根目录下,有个.git的隐藏文件,进入有一个config文件,编辑打开,修改[remote "origin"]标签下的fetch字段,修改前是clone -b指定的分支,改成*星号全部分支:

url = xxx
fetch = +refs/heads/*:refs/remotes/origin/*

执行git pull -rebase

执行git pull -rebase是为了与远程同步,执行之后用git branch -r命令就能看到所有分支了。
用Sourcetree相当于下图这个操作:

Sourcetree Pull

git checkout其他分支

看到其他分支,就说明可以切换到其他分支了

相关文章

  • git 常用命令

    1、clone项目 git clone 仓库地址 直接clone指定分支git clone -b 分支名 仓库地址...

  • git操作

    git clone 拉git近期代码 -b master --depth=1 第一步 add 第二步本地提交,信息...

  • git只拉取最新版本

    git clone 中加入参数 --depth=1,只拉取最近的一个 revision。 git clone --...

  • 快速拉取远程仓库代码

    指定分支 git clone -b + 要clone的分支名 + 仓库地址 git clone -b devel...

  • 【Git】基本操作

    一、拉取代码 1. 拉取指定分支代码 git clone -b [URL] 2. 拉取远程仓库代码(拉取远程仓库代...

  • git 拉取指定远程分支

    git clone-b分支名 仓库地址 eg: git clone -b my-branch http://xxx

  • centos7上安装odoo13

    安装gityum install git 克隆odoo13源码git clone --depth=1 -b 13....

  • Git常用命令

    远程仓库 clone git clone [-b branch] git@server:repo [local_d...

  • git 常见命令

    分支操作 使用 Git下载指定分支命令为:git clone -b分支名仓库地址 拉取远程新分支 git chec...

  • git 使用

    克隆仓库 git clone [仓库地址]克隆远程分支的一个分支 git clone -b

网友评论

    本文标题:git clone --depth -b 选择性拉仓库

    本文链接:https://www.haomeiwen.com/subject/oodexdtx.html