zoukankan      html  css  js  c++  java
  • 三分钟教你学Git(十四) 之 线下传输仓库

    有时候还有一个人不能从远程直接clone仓库或者说由于非常大,clone非常慢或其他原因。我们能够使用bundle命令将Git仓库打包,然后通过U盘或者是其他介质拷贝给他,这样他拿到打包好的仓库后能够unbundle成仓库,达到了共享的目的,这样有时候是非常方便的。


    我们看看详细怎么做:

    首先我们进入仓库。git status一下看看当前的仓库状态。


    然后開始打包:

    git bundle create zhc.bundle HEAD master

    Counting objects: 6, done.
    Delta compression using up to 2 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (6/6), 447 bytes, done.
    Total 6 (delta 0), reused 0 (delta 0)


    HEAD master说明我们想生成关于master分支的全部信息。然后我们就看到生成了一个zhc.bundle文件,将此文件拷贝给其它人。还有一个人拿到此文件后,能够依据它创建本地仓库。

    開始解包成本地仓库:

    git clone zhc.bundler repo

    然后我们就看到多了一个repo目录,此目录便是那个git仓库了。


    有时候我们还想仅仅打包当中的一些commits。而不是一个分支上的全部commits。那么我们能够使用range commit来告诉bundle要打包哪些commits。


    git bundle create zhc.bundle master ^origin/master

    这条命令的意思是仅仅打包那些在master中而不在origin/master分支中的commits。

    拿到此bundle后,能够先验证一下:

    git bundle verify ../zhc.bundle

    The bundle contains 1 ref
    84dx35f49 refs/heads/master

    The bundle requires these 1 ref

    sd2ffe8sdf hongchangfirst commit

    ../zhc.bundle is okay


    看到此bundle是完整的而且含有你想要的内容,然后看一下这个bundle文件的内容看看我们能够引入哪些commit。

    git bundle list-heads ../zhc.bundle


    然后我们就能够開始引入了:

    git fetch ../zhc.bundle master:zhc-branch

    就是将bundle中的master分支中的commits增加到本地的zhc-branch上。

    原文:http://blog.csdn.net/hongchangfirst/article/details/45579417

    作者:hongchangfirst

    hongchangfirst的主页:http://blog.csdn.net/hongchangfirst





  • 相关阅读:
    避免前置声明
    CLion在WSL上远程调试代码设置
    push_back与构造函数
    _BLOCK_TYPE_IS_VALID(pHead->nBlockUse问题解析
    Qt报错
    关于引用与指针实现多态的一些记录
    Vue-Axios异步通信
    Kafka概述
    学习Ajax看着一篇就够了
    学习Json看着一篇就够了
  • 原文地址:https://www.cnblogs.com/blfbuaa/p/6807317.html
Copyright © 2011-2022 走看看