views:

132

answers:

4

I'm using github as a repo for a little project, but I'd also like to use some code written by another github user.

Is it possible to setup a /library/libraryname folder inside my project which maintains it's links back to the other users repo as well as being part of my projects commits?

For example: If the other user updates their code later on, I'd like to be able to easily fetch their changes while still keeping it in the same repo as my main project.

A: 

-- edit

Removed my claim that it's 'probably not possible'. Rest of my argument is still valid.

But anyway, generally, you don't want to get updates so fast like that. You'd prefer to have a 'stable' version of his library, and update it only when another 'stable' version is released (as tested by you; not neccessarily one considered 'stable' by him).

So even if you could (but in SVN, which I use, you can't, but I don't know about git specifically) you wouldn't want to.

Noon Silk
It can be easily achieved with so-called externals
iElectric
Yea obviously I wouldn't want to update the external library all the time, but I wondered if there was a better way than just downloading a .zip of the changes and putting it into my repo.
Tom
iElectric - Didn't know that. Thanks.Tom my point is that even if you could, it's good practice not to do it.
Noon Silk
+3  A: 

I think you're probably looking for the git submodule command. Also have a look at the Git Submodule Tutorial.

Greg Hewgill
Yep I think I do want submodules, Thanks for the link to the Tutorial.
Tom
It looks like submodules only represent a specific commit number of another repo, and they require a submodule push before pushing the super project to show all changes. Can anyone confirm these limitations?
Chris
+1  A: 

If you want, you can use git subtree instead of git submodule. This is a little bit more convenient to use, and doesn't require people who checkout from your repository to know anything about submodules or subtrees. It also makes it easier to maintain your own patches to the subproject until you're ready to submit them upstream.

apenwarr