user2075215
user2075215

Reputation: 379

best way to combine git repositories

I'm looking at the best way to use a single or multiple git(hub) repositories in a new project, so that I can pull updates from the original git source.

So if I have foo.git and bar.git and I start a new project baz.git. What is the best way to have foo and bar in the baz repository? Should I just clone them in the new directory or use git merge or something else?

I don't want to lose the history and connection to the original repo for foo and bar because I still would like to pull updates when needed.

Thank you.

Upvotes: 0

Views: 42

Answers (1)

Frederic Close
Frederic Close

Reputation: 9639

It looks like what you are looking for is git submodule

http://git-scm.com/docs/git-submodule :

Submodules allow foreign repositories to be embedded within a dedicated subdirectory of the source tree, always pointed at a particular commit.

They are not to be confused with remotes, which are meant mainly for branches of the same project; submodules are meant for different projects you would like to make part of your source tree, while the history of the two projects still stays completely independent and you cannot modify the contents of the submodule from within the main project.

more info about submodules: http://git-scm.com/book/en/v2/Git-Tools-Submodules

Upvotes: 1

Related Questions