1

I have a big git folder that contains all of my programming studies. Sometimes I have to clone a remote git folder into this big folder, thus creating a git working directory within another one.

I actually want them to co-exist because a IDE that I use (Rstudio) create its project based on git, and I want my Rstudio project to be contained within the smaller folder only.

Is it possible or will it cause trouble? In that case, should I just clone the small folder then delete the .git folder?

Heisenberg
  • 8,386
  • 12
  • 53
  • 102

2 Answers2

2

Git already has a feature for this setup called Git submodule which allows you to include external Git repositories within a single project.

To use submodules save each of your individual projects into their own Git repository. Then in your master project (your main programming studies Git repository) you include them using the git submodule add <path-to-individual-project-repository> command.

After you add the submodules don't forget to do a git submodule update --init to checkout the files from your individual projects.

1

It is possible, and you even can record the nested repo within the parent repo as a submodule.

That way, the main repo keep track of the exact version of the little repo you are working with.

And since git 1.8.2, you even can ask for your nested (submodule) repo to always be at the latest of its own master branch.
See "git submodule tracking latest" for more.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250