Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git init in a git subdirectory

I have a git repo which has some subdirectories:

  ~/src
  ~/src/.git
  ~/src/mystuff
  ~/src/otherstuff

Now I want to share otherstuff with a friend, I was planning to do this with bitbucket. They should be able to clone it and push changes in otherstuff but I don't want them to be able to access src, mystuff (nor even see that they exist).

How do I go about this? I almost went into cd ~/src/otherstuff and did git init, git remote add origin ssh://[email protected]/wim_glenn/... but something doesn't smell right about doing git init again when it's already under version control.

like image 252
wim Avatar asked Mar 12 '13 05:03

wim


1 Answers

Making a git init within a git repo works: the directory in which you init the nested repo simply becomes ignored by the parent repo.

However, if the history of that subdirectory is important, is is best to export it as a separate repo (as Nick suggested).
From there, you can keep both repos in lock steps by declaring that new repo as a submodule of the parent repo.

like image 198
VonC Avatar answered Oct 19 '22 06:10

VonC