Git bundle is a command-line utility in Git that allows you to create and share a repository without using a remote server. It packages all the necessary Git objects and references into a single file, which can be used to transfer a repository over a network or store it in an archive.
Here’s how to create a bundle file:
git bundle create repo.bundle HEAD master
This command creates a bundle file called repo.bundle that contains all the Git objects and references necessary to represent the current state of the HEAD and master branches.
You can transfer this bundle file to another location using any method you prefer, such as email or USB drive. Once you have the bundle file on another machine, you can extract it into a new Git repository using the git clone command with the –bare and –mirror options:
git clone --bare --mirror repo.bundle new-repo.git
This creates a new repository called new-repo.git that is an exact copy of the original repository, including all branches, tags, and commits.
Using git bundle has several advantages over other methods of sharing a repository. It allows you to transfer a repository without requiring network access or a remote server, which can be useful in situations where you don’t have reliable internet access or when you want to share a repository with someone who doesn’t have access to your server. It also provides a secure way to transfer a repository, as the bundle file is signed by the creator’s GPG key, ensuring the integrity of the repository contents.