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
>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.