19

I'm new to github.

I have a github repo on my machine. I want to include another repo (as a third party) into my repo. I believe I should make a fork first. But how do I include it on my local repo?

I've tried submodules but with no success...

Thanks.

Ben James
  • 121,135
  • 26
  • 193
  • 155
ramaralo
  • 1,013
  • 2
  • 10
  • 15
  • 1
    You do not need a submodule unless you want to make it easier to automatically include another git repository. It is the recommended way though. If you want a quick test then just clone the repository into yours and work away. You will not go to far wrong. The root of each git repo will have a `.git` for that repo, using submodules will allow your repo to know about the other one, otherwise you are hiding it from yours. – dirvine Jul 21 '13 at 19:15
  • 2
    In what way did using submodules result in 'no success'? – AD7six Jul 21 '13 at 19:22

1 Answers1

34

git submodule remains the recommended way: you can declare (git submodule add) a repo which doesn't belong to you, or a fork (which, by definition, belongs to you).

Don't forget though, that:

  • you still need to git submodule update --init in order to see that submodule repo being displayed with its full content in your repo
  • add and commit the special entry representing the root directory of that submodule in your main (parent) repo, and push that commit, in order to validate that declaration.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 2
    This answer is generalized for Git. The OP asked about GitHub, which presumably uses its own client. – ATL_DEV Oct 26 '17 at 14:47