github linking with other repos
Asked Answered
G

3

89

I have a project that relies on two repos in github to function. When I submit my project to github how do I link to these two repos? Should I duplicate the files in my own repo or link to the other repo at a specific revision as I don't want it to update and cause incompatibility. I already created my github repo what should I do?

Gallaher answered 20/2, 2012 at 7:13 Comment(0)
L
71

You can use git submodules to "link" to other projects.

See here - https://github.blog/2016-02-01-working-with-submodules/

Ligament answered 20/2, 2012 at 7:17 Comment(4)
What if my project has nothing to do to contribute towards the original repo I depend on? For instance I'm using an XML parser for my script but it's not nothing to do to contribute towards that project, should I still use submodules?Gallaher
@Gallaher Yes, it is not just about contributing to the other project.Ligament
last question when you update files inside that submodule if you push changes does it update my or the linked repo?Gallaher
@Gallaher - You said you are not contributing to it. If you push, it will (try to) update the linked repo.Ligament
B
21

There is an alternative to submodules that I found out to be more practical: subtree.

According to this link the advantages are:

  • Management of a simple workflow is easy.
  • Older version of git are supported (even before v1.5.2).
  • The sub-project’s code is available right after the clone of the super project is done.
  • subtree does not require users of your repository to learn anything new, they can ignore the fact that you are using subtree to manage dependencies.
  • subtree does not add new metadata files like submodules doe (i.e. .gitmodule).
  • Contents of the module can be modified without having a separate repository copy of the dependency somewhere else.
Bianka answered 25/11, 2013 at 9:32 Comment(1)
Nice tip! Strange to hear about it more that 10 years after this answer. Which (and the promising summary of the feature) begs the question: what are the drawbacks then? Surely there must be drawbacks; esp. as the entire interwebs hype network is mostly silent about it.Cream
S
20

GitHub will also allow you to reference another repository in a comment on GitHub or in a commit. For example:

We should probably handle this with github/enterprise#59

This will add an update to the issue github/enterprise#59 with a link to your comment/commit.

Cross-Repository Issue References

enter image description here

Sure, GitHub's all about social coding, but you can have social repositories, too. You can reference issues between repositories by mentioning user/repository#number in an issue. Once we see something like that — say, github/enterprise#59 — we'll make sure to update issue #59 in github's enterprise repository and let you know where it was referenced from. This is a part of GitHub Flavored Markdown, which also has a few tricks of its own.

Read more: https://github.com/blog/967-github-secrets

Sciatica answered 30/1, 2014 at 20:16 Comment(1)
Does this also work for private repos? Some early tests show maybe not, even from within the same organization.Clinic

© 2022 - 2024 — McMap. All rights reserved.