My submodule repository is morethan 2 gb. whenever i do adding the submodule to my localrepo its cloning the entire submoudle remote repository.
git submodule add -f -b localbranch https://mygitserversuperprojecturl/server.git .submodule/server_git
result:- Cloning into 'submodule/server_git'...
so usually it takes morethan 1 hour to get complete could anybody help me to add particular branch without adding the entire submodule remote repo.
git verison 1.8.3.1
Thanks.
If you can upgrade Git (to at the very least 1.8.4, but preferably to 2.16.2), you can benefit from shallow clone submodule: that will avoid cloning the full history.
The OP adds:
Since there is a
--single-branchoption togit clone, you can add your submodule in two steps, as seen here:By cloning only
myBranch, you won't clone the full 2GB repo.By not adding
--depth 1, you will get the full history of that branch.The OP details:
Then this is a job for
git worktree(Git 2.5+, so do upgrade Git first):Clone your Git repo once, but checkout it twice, one per branch.
That way, you have two different folders with two different branches already checked out. Switching branch is then very quick, and updating those branches (
git pull) is faster than a full checkout.