views:

105

answers:

4

I have created a bare git repo (lets call it repo #1) and cloned it. In the clone (repo #2) I have created several folders, one of which I have decided to make a git repo (repo #3). When I commit to repo #2, everything runs as expected exept that repo #3 is ignored (the .git folder, the files commit). How can I add repo #3 to repo #2 so that when I push repo #2 to repo #1, I can make a seperate clone of repo #1 in which I can also access the history etc. of repo #3?

In other words. How do I create a git repository that contains another git repository?

+6  A: 

I don't know how to do exactly what you are suggesting, but sub-modules probably come close (or as close as you are going to get). Here is a decent tutorial:

http://git.or.cz/gitwiki/GitSubmoduleTutorial

megamic
+2  A: 

see git submodule

i’ve never used it, so all i can do is post a link …

knittl
+2  A: 

I'm not a GIT pro by any means, but i think you are referring to git submodules

git submodule --help
Question Mark
+1  A: 

You shouldn't do that. Metadata under .git/ is changed during repo lifetime and that changes not necessarily mean "changes in the content" that should be committed: simple git repack changes files under .git but that changes should not be committed. Why do you want to do that?

wRAR
I am using the parent repo (#2) to facilitate easy backing up of the folders that it contains which includes repo #3. Everything is stored on a USB drive and this way I can easily push a backup of everything to my backup location (repo #1).It seems that I will just have to manually copy the folders to back them up for now.
Pheter
If everything you want is just a backup of all repositories (and working copies), then you might just use something that doesn't know anything about git ant it's structure, for example mercurial or bazaar.As wRAR said it would add lots of stuff that you dont need, but if you just want a backup then it might be ok. But you could also just write a script that goes through every repository on your stick and pushes it to the server.
Tomas Markauskas