Restore git submodules from .gitmodules

git submodule init only considers submodules that already are in the index (i.e. “staged”) for initialization. I would write a short script that parses .gitmodules, and for each url and path pair runs: git submodule add <url> <path> For example, you could use the following script: #!/bin/sh set -e git config -f .gitmodules –get-regexp ‘^submodule\..*\.path$’ … Read more

How do I revert my changes to a git submodule?

A more fail-safe method than all previous answers: git submodule deinit -f . git submodule update –init The first command completely “unbinds” all submodules, the second then makes a fresh checkout of them. It takes longer than the other methods, but will work whatever the state of your submodules.

How to handle a transitive dependency conflict using Git submodules and CMake?

There are several approaches for detect and discard inclusion of the project, which has already be included in some other parts of the main project. Check project’s target existence The simplest pattern for single inclusion of subproject is checking existence of some subproject’s target: # When include ‘C’ subproject if(NOT TARGET library_C) add_subdirectory(C) endif() (Here … Read more

How can I get a git submodule’s associated commit ID from a past commit in the parent clone?

You may use git-ls-tree to see what the SHA-1 id of a given path was during a given commit: $ git ls-tree released-1.2.3 foo 160000 commit c0f065504bb0e8cfa2b107e975bb9dc5a34b0398 foo (My first thought was git show released-1.2.3 foo, but that fails with “fatal: bad object”.) Since you are scripting the output, you will probably want to get … Read more

Git submodules not updating in Jenkins build

Note that the Jenkins Git plugin 2.0 will have “advance submodule behaviors”, which should ensure proper updates of the submodules: As commented by vikramvi: Advanced sub-modules behavior > “Path of the reference repo to use during submodule update” against this field , add submodule git url. Owen B mentions in the comments: For the authentication … Read more

Is there a way to use a Mercurial repository as Git submodule?

Using git-hg. First, make sure there is a (non-Mercurial) git submodule under your main repository. If you don’t have other submodules yet, just create a dummy submodule for some library other than core-plot, for instance: main-repo $ git submodule add https://repo.url.com/repo.git repo Second, clone the core-plot library into some directory. main-repo $ git-hg clone https://code.google.com/p/core-plot/ … Read more