How can I send someone the most recent version of one branch of my git repo without version control history?

673 views Asked by At

I'm trying to send someone a copy of the current state of one branch on my Git repository. He doesn't have access to the repository itself and doesn't need version control history. I would also like to send the file over email, so including excessive history will cause the file size to be too large.

I could manually clone that branch myself with --depth=1 in a new folder, then compress that folder and send it, but that seems like a roundabout way to accomplish what could be done with git-bundle. However, if I do git bundle create repo.bundle -1 HEAD, which according to https://git-scm.com/docs/git-bundle should bundle only the 1 most recent commit, I get a 590 B file and an error when I try to clone from the bundle to test it:

error: Repository lacks these prerequisite commits:
error: 123456...             # example SHA, HEAD~1
fatal: bad object 789101...  # example SHA, HEAD
fatal: remote did not send all necessary objects

How can I get only the most recent version of the branch from my local repository?

1

There are 1 answers

0
mnestorov On

If your friend doesn't need the .git directory on his machine, then you don't need to zip it. You just need to archive your project from the tip of the branch you are.

cd my-project

git checkout my-feature-to-share

zip -r my-project.zip .

This will produce an archive that you can freely share to your friend. If you wish to NOT share the .git folder, you can exclude it with the -x option.