Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git repo inside repo [duplicate]

I want to clone https://github.com/getyouridx/pychargify into my django project, and will need to pull updates from time-to-time.

Just for clarification, could I simply write a gitignore from the root directory of the django project e.g. .gitignore: pychargify/.git or are there other pitfalls I should be aware of?

like image 978
null Avatar asked Dec 01 '11 00:12

null


People also ask

Can I clone a repo inside a repo?

Just for the record, you can clone a git repo within another one: Everything under your lib directory will be ignored by the enclosing Git repo, because said lib directory contains a . git . That means cloning the enclosing repo, and you will get an empty " lib/ " folder.

Can I have nested git repositories?

Git allows you to include other Git repositories called submodules into a repository. This allows you to track changes in several repositories via a central one. Submodules are Git repositories nested inside a parent Git repository at a specific path in the parent repository's working directory.


2 Answers

To have one git repo "inside" another, look at git submodules: http://git-scm.com/book/en/Git-Tools-Submodules

By making pychargify a submodule of your django project, specific revisions of your django project can be associated with specific revisions of your pychargify project. That can be really useful.

I'm not sure exactly what the dangers are of the approach you describe, but it doesn't pass the smell test for me. I would recommend using the Git feature (submodules) that is designed specifically for this type of thing.

like image 86
Trott Avatar answered Oct 07 '22 14:10

Trott


Git has a feature for having a repository within another: submodules.

git submodule add https://github.com/getyouridx/pychargify.git 

Be sure to read the entire documentation on submodules, as there as a few quirks involved with using them, and additional steps that need to be taken when doing a fresh clone of your own repository to initialize the submodules.

Also note that all submodule commands must be done in the root directory of your repository.

like image 37
Andrew Marshall Avatar answered Oct 07 '22 14:10

Andrew Marshall