On Monday, July 16, 2012 4:32:59 PM UTC+2, Nedvajz wrote:
> The link you posted is almost what i want. 
> So this i my last try of explain what i am looking for:
> 1) I want to *clone* only part of some repository and made new one.
> This new repo will have only master branch even if the origin has more 
> branches.
> This new repo will have only commits of the master branch even if the 
> origin has more commits of other branches. (the new repo will be smaller in 
> size = number of commits).
> 2) I wont lose ability work with old repo. 
> Push/Pull to/from origin master branch.
> Making new branches in new repo, and pull them onto origin repo.
> 3) But till I directly set (somehow) this new git repo. It wont fetch any 
> new branches and/or get any commits which doesnt belong to master branch 
> from origin repo.
> So I make summary. The link you posted allow me work like i want, but it 
> works with basic repo. I need this to work *on* *submodules*.
> So when I will work with project, and make changes in submodules and then 
> I will clone whole project somewhere and run "git submodule update" all 
> submodules will fetch only needed branch with its commits only(like it is 
> in link, but for *submodule here*)
> Thanks for you patience!

Sounds pretty straight forward: Set up a bare repository that tracks only 
one branch like in the link described, and then link it in as a submodule, 
the same way you would do with any submodule:

git clone original masteronly-bare.git
cd masteronly-bare.git
git branch -D unwanted-branch-A
git branch -D unwanted-branch-B
git gc --prune=now  #removes the now unreferenced commits

Now, go into your other repo where you want the submodule with the single 

cd ../super-repo
git submodule add ../masteronly-bare.git submoduleX

Now you can push changes in the submodule back to the branchless-bare.git:

cd submoduleX
git checkout master
echo foo >> work.txt
git commit -am "Working in master"
git push origin master

And when you want to sync the changes back to the original repo with all 
the branches, pull from the branchless-bare:

cd ../../original/
git remote add bb ../masteronly-bare.git
git checkout master
git pull bb master

Recap: Only your *original* repo is now aware of all the branches. In the 
super-repo, as well as in the masteronly-bare, there is no knowledge of the 
"secret" branches, but you can still pull commits in master back to the 
original via the masteronly-bare repository.

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To view this discussion on the web visit 
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to