Search code examples
gitgit-bundle

Archiving entire git repo


I have to move servers and need a way to pack my git repo. All branches, tags and CI/CD pipeline. I have used git bundle in the past, but that only packs a single branch. Is there a way to pack,zip the entire repo branches, tags and pipelines?


Solution

  • There're many ways to transfer repository completely. Mirror-push to a repo at any server you can create a repository: git push --mirror remote-repo; later clone the pushed repo back. Config and hooks are not pushed, you need to transfer them manually.

    You can use git bundle, it allows to bundle any number of references, see the docs for git bundle create and git-rev-list-args. Try this: git bundle create repo.bundle $(git rev-parse --abbrev-ref=loose --all). Config and hooks are still not bundled.

    The most complete solution is to zip the entire .git directory: zip -r repo.zip .git. Everything will be in the archive except for unstaged files.