How to git bundle a complete repo

后端 未结 3 741
陌清茗
陌清茗 2020-11-28 18:19

I need to transfer a complete repo to a new non-networked machine, preferable as a single file entity. The git bundle allows a git fetch, git pull

相关标签:
3条回答
  • 2020-11-28 18:33

    First clone the repository, and include the --mirror option.

    git clone --mirror git@example.org:path/repo.git

    This ensures all remote branched are also local branches ready for bundeling.

    Then run

    git bundle create repo.bundle --all as described by the answer from Jakub Narębski

    0 讨论(0)
  • 2020-11-28 18:43

    I would suggest you tar or zip the .git folder and simply unpack it in the new location and then do git reset --hard HEAD. Everything required for all the branches is under .git and all you should need to do is adjust any remotes in the .git/config file or remove them.

    tar cf myrepo.tgz .git
    cp myrepo.tgz [USB_STICK]
    ... move to new machine ...
    mkdir myrepo && cd myrepo
    tar xpf [USB_STICK]/myrepo.tgz
    git reset --hard HEAD
    
    0 讨论(0)
  • 2020-11-28 18:56

    What is the right invocation to:

    • Bundle all the branches in the current repo

    Simple:

    $ git bundle create repo.bundle --all
    

    Here repo.bundle is the name of bundle file you want to create. Note that --all would not include remote-tracking branches... just like ordinary clone wouldn't either.

    • Start up the new repo on the destination directory, i.e. get the root commit correctly installed

    First, clone is just init + fetch (+ administrativia).

    Second, you can use bundle file everywhere the repository URL can be used, so you can simply clone from a bundle file:

    $ git clone repo.bundle
    

    This would create repo as a git repository.

    0 讨论(0)
提交回复
热议问题