How to bundle/export a git repo as a single file without losing the git history

princewilliroka

Princewill Iroka

Posted on May 22, 2021

How to bundle/export a git repo as a single file without losing the git history

Sometimes, you need to export and send a git repository to someone for code review.
In such cases, you may not have the option of adding the person to the repository as a collaborator on Github, Gitlab, Bitbucket or any other git-based version control platform.
You can use these steps to export the git repo as a single file:

  • Clone the repo if you haven't already done so:

git clone reponame

  • Inside the root directory of the project, bundle the repo by running this from the command line:

git bundle create reponame.bundle --all

Note: This will bundle all the branches in the repo in a repo.bundle file that can be easily sent to someone.

  • Use this to bundle only the main branch:

git bundle create reponame.bundle main

  • When the person receives the file, the person can unbundle it using this command:

git clone reponame.bundle

Note: Ensure to delete the node_modules folder before bundling your repo

For more info on bundling Git repos, read this Stackoverflow question or the official Git docs

💖 💪 🙅 🚩
princewilliroka
Princewill Iroka

Posted on May 22, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related