Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a way to do a git mirror clone on a specific branch?

I need to mirror clone on a specific branch and copy the history connected to that branch. The repo it is connected to is too large to do a mirror clone and push so need to target a specific branch.

I tried to do ‘git clone –mirror -b BRANCHNAME url’ but it is still too large but I’m not even sure if it working how I would like it to

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Replace --mirror with --single-branch.

--mirror is for expanding the list of refs you fetch, to include even the administrative / inflight-operation-tracking / backout refs that aren’t strictly part of the project history, more just the repository-specific operational metadata.

You get the complete history of any ref you do fetch unless you explicitly truncate the fetch with a limit like --depth=1, whatever you don’t have yet the remote will send you.

-b branchname explicitly sets which ref git clone will use for the initial checkout it does for you but it doesn’t limit what you fetch.

For cloning from very large repositories like the aosp I’ve taken to suggesting --filter=tree:0 instead of --depth or --single-branch limits, that gets you the barest sketch of the complete history and fetches the rest on demand, it seems to work well.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading