Questions tagged [git-submodules]

Submodules allow you to keep a Git repository as a subdirectory of another Git repository.

A Submodule allows you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate. [Pro Git book]

The parent repo keep track of a submodule in:

  • a .gitmodule file (for the url of the sub repo)
  • a special entry in its index, called gitlink for the SHA1 to which the submodule is checked out (a submodule is always initialized in a detached HEAD mode)

Common questions:

2611 questions
3790
votes
31 answers

How do I remove a submodule?

How do I remove a Git submodule? By the way, is there a reason I can't simply do git submodule rm whatever ?
R. Martinho Fernandes
  • 209,766
  • 68
  • 412
  • 492
2227
votes
17 answers

How to "git clone" including submodules?

I'm trying to put a submodule into a repo. The problem is that when I clone the parent repo, the submodule folder is entirely empty. Is there any way to make it so that git clone parent_repo actually puts data in the submodule folder? For example,…
Mark
  • 22,311
  • 3
  • 14
  • 6
2055
votes
20 answers

Easy way to pull latest of all git submodules

We're using git submodules to manage a couple of large projects that have dependencies on many other libraries we've developed. Each library is a separate repo brought into the dependent project as a submodule. During development, we often want to…
Brad Robinson
  • 37,220
  • 16
  • 51
  • 82
947
votes
15 answers

Update Git submodule to latest commit on origin

I have a project with a Git submodule. It is from an ssh://... URL, and is on commit A. Commit B has been pushed to that URL, and I want the submodule to retrieve the commit, and change to it. Now, my understanding is that git submodule update…
Thanatos
  • 37,926
  • 14
  • 76
  • 136
849
votes
12 answers

How can I specify a branch/tag when adding a Git submodule?

How does git submodule add -b work? After adding a submodule with a specific branch, a new cloned repository (after git submodule update --init) will be at a specific commit, not the branch itself (git status on the submodule shows "Not currently on…
Ivan
  • 77,768
  • 15
  • 47
  • 57
809
votes
8 answers

How to change the remote repository for a git submodule?

I've created a git repository with a submodule in it. I'm able to tell the submodule itself to change its remote repository path, but I'm not sure how to tell the parent repository how to change the remote repository path for the submodule. I…
Andrew Grimm
  • 70,470
  • 47
  • 186
  • 310
502
votes
29 answers

How do I pull from a Git repository through an HTTP proxy?

Note: while the use-case described is about using submodules within a project, the same applies to a normal git clone of a repository over HTTP. I have a project under Git control. I'd like to add a submodule: git submodule add…
James A. Rosen
  • 60,042
  • 58
  • 173
  • 260
416
votes
12 answers

How to un-submodule a Git submodule?

What are the best practices for un-submoduling a Git submodule, bringing all the code back into the core repository?
Quickredfox
  • 4,211
  • 3
  • 15
  • 6
400
votes
10 answers

How do I move an existing Git submodule within a Git repository?

I would like to change the directory name of a Git submodule in my Git superproject. Lets suppose I have the following entry in my .gitmodules file: [submodule ".emacs.d/vimpulse"] path = .emacs.d/vimpulse url =…
thisch
  • 4,181
  • 3
  • 14
  • 14
357
votes
15 answers

No submodule mapping found in .gitmodule for a path that's not a submodule

I have a project that has a submodule at lib/three20 My .gitmodule file looks like this: [submodule "lib/three20"] path = lib/three20 url = git://github.com/facebook/three20.git I have cloned this in the past without errors, (git submodule…
Ben Scheirman
  • 39,034
  • 20
  • 96
  • 135
345
votes
5 answers

How do I add a submodule to a sub-directory?

I have a git repo in ~/.janus/ with a bunch of submodules in it. I want to add a submodule in ~/.janus/snipmate-snippets/snippets/, but when I run git submodule add in the snipmate-snippets directory, I get the following error…
Robert Audi
  • 7,199
  • 8
  • 41
  • 65
326
votes
4 answers

Git update submodules recursively

My project struture ProjectA -FrameworkA (submodule) --Twig (submodule of FrameworkA) How I can update submodules recursively? I already tried some git commands (on ProjectA root) git submodule foreach git pull origin master or git submodule…
complez
  • 6,552
  • 11
  • 44
  • 54
324
votes
4 answers

Differences between git submodule and subtree

What are the conceptual differences between using git submodule and subtree? What are the typical scenarios for each?
Nathan H
  • 44,105
  • 54
  • 154
  • 235
320
votes
13 answers

Git submodule head 'reference is not a tree' error

I have a project with a submodule that is pointing to an invalid commit: the submodule commit remained local and when I try to fetch it from another repo I get: $ git submodule update fatal: reference is not a tree:…
Mauricio Scheffer
  • 96,120
  • 20
  • 187
  • 273
317
votes
8 answers

Update a submodule to the latest commit

I have a project A which is a library and it is used in a project B. Both projects A and B have a separate repository on github BUT inside B we have a submodule of A. I edited some classes on the library, which is in the repo A, I pushed on the…
fat
  • 3,929
  • 3
  • 24
  • 31
1
2 3
99 100