How to git mirror some specified branch I wanted -


i'm using repo contains hundreds of branch(because repo used lots of products). such as: $ git branch -a

remotes/origin/brancha

remotes/origin/branchb

remotes/origin/branchc

remotes/origin/branchd

......

but need few branch(may branch a, b) of repo. there way mirror , b repo? each time used git branch on mirrored repo, confused, , wastes lot of system resources.

this commonly used repo in company, lots of products using it. has lot of different branches. but, i'm work on of these product(in fact still above 20 above products), don't take care other branches, want mirror mine. use git clone --mirror mirror branches want?

while may beyond power make happen, best solution put each product in own repo. have there sounds happens when versed in tfvc tries use git without learning git first. expect cause additional problems besides 1 you're facing.

since have deal is, here can do:

you can control fetch refspec used clone.

git config remote.origin.fetch <refspec> 

in case branches namespaced product, easy. example, if repo has branches like

product_a/branch_1 product_a/branch_2 product_b/branch_1 ... 

then use fetch refspect +refs/heads/product_a/*:refs/remotes/origin/* repo clones product_a, or +refs/heads/product_a/*:refs/remotes/origin/product_a/* +refs/heads/product_c/*:refs/remotes/origin/product_c/* if want clone couple products (though, again, don't recommend latter).

but i'm guessing layout isn't convenient, , may have specify individual branches want, e.g. +refs/heads/branch_1:refs/remotes/origin/branch_1 +refs/heads/branch_3:refs/remotes/origin/branch_3 .... problem here is, if feature branches come , go, have manually add , remove them (or deal them other way). cure may worse disease.

anyway, putting together, create clone product uses couple specific branches, say

git clone --single-branch -b branch_1 remote_repo_url my_product_a_repo cd my_product_a_repo git config remote.origin.fetch +refs/heads/branch_1:refs/remotes/origin/branch_1 +refs/heads/branch_3:refs/remotes/origin/branch_3 +refs/heads/branch_37:refs/remotes/origin/branch_37 git fetch 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -