9

What does this green icon mean in Github? I know the commit link takes me to another repository. I need to do something similar. Is this a symlink? Or a submodule? Being still somewhat new to git, I'm wondering how I can replicate this myself. Once created, how do I update this external dependency?

Git repository - what's up with the green icon?

TimDog
  • 8,758
  • 5
  • 41
  • 50

2 Answers2

16

This is a submodule: a link to a specific commit in another repository at a different URL. The repository will be cloned when git submodule update --init is run, and then the referenced commit (784fd39) will be checked out.

You can create submodules using git submodule add <url> <directory>, which will add a submodule reference for the given URL at the directory you specify, in the current working directory.

cdhowie
  • 158,093
  • 24
  • 286
  • 300
  • great thanks -- assuming the file gets updated with a different commit, how do I re-init the submodule to go at the latest commit? Or does running `git submodule update` once the `init` has already take place automatically link the submodule to the latest commit? – TimDog Jan 21 '13 at 22:53
  • @TimDog No, that will update the checked-out clone to point to the commit referenced by the submodule. To update the cloned repository to the latest commit, just `cd` into that repository and run `git pull --ff-only` like you usually would. Then you will have to `git add` the changed submodule and `git commit` the result in order for this change to be committed to your outer repository. (Which commit to check out in a submodule is as much a history of the repository as anything else.) – cdhowie Jan 21 '13 at 23:02
  • @TimDog I'd be surprised if that worked -- submodules cannot reference individual files, nor can they reference subdirectories. You will receive an error when you `git submodule update --init` as that URL does not point to a repository at all. – cdhowie Jan 21 '13 at 23:02
  • thanks for the tips. I deleted my errant comment about the indiv file (because you were right, that didn't work). So there is no way to link to just a single file from a repo? (I realize that's a separate question altogether). – TimDog Jan 21 '13 at 23:08
1

You can use this method here. It's from another question in So, That topic is What does a grey icon in remote GitHub mean You can ignore submodule step which is very complex.

Tran Hung
  • 11
  • 3
  • 1
    Can you please add some of the information from that article to your answer so it can be accepted to the SO community? – Marcello B. Jan 12 '18 at 02:26