1

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
  • Perhaps, there's a smarter way to do this, but just removing .git folder should do the job. Commented Sep 3, 2020 at 12:14

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.