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 .gitmodules file (for the url of the sub repo)
  • a special entry in its index, called gitlink for the commit hash at which the submodule is checked out (a submodule is always initialized in a detached HEAD mode)

Common questions:

3102 questions
4430
votes
37 answers

How do I remove a submodule?

How do I remove a Git submodule? Why can't I do git submodule rm module_name?
R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510
2606
votes
24 answers

How do I "git clone" a repo, including its submodules?

How do I clone a git repository so that it also clones its submodules? Running git clone $REPO_URL merely creates empty submodule directories.
user578895
2527
votes
23 answers

Pull latest changes for 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
  • 44,114
  • 19
  • 59
  • 88
1112
votes
17 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
  • 42,585
  • 14
  • 91
  • 146
1086
votes
14 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
  • 97,549
  • 17
  • 50
  • 58
962
votes
9 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
  • 78,473
  • 57
  • 200
  • 338
533
votes
30 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
  • 64,193
  • 61
  • 179
  • 261
508
votes
12 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
  • 5,261
  • 3
  • 16
  • 14
479
votes
13 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,841
  • 3
  • 18
  • 6
425
votes
9 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
  • 5,098
  • 4
  • 28
  • 31
423
votes
15 answers

How do I revert my changes to a git submodule?

I have a git submodule (RestKit) which I have added to my repo. I accidentally changed some files in there and I'd like to go back to the source version. In order to do that, I tried to run Mac:app-ios user$ git submodule update RestKit But as you…
Eric
  • 5,815
  • 3
  • 25
  • 34
415
votes
5 answers

How do I add Git 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
  • 8,019
  • 9
  • 45
  • 67
409
votes
7 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
  • 7,882
  • 11
  • 48
  • 56
408
votes
19 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
  • 40,531
  • 21
  • 102
  • 137
403
votes
6 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
  • 48,033
  • 60
  • 165
  • 247
1
2 3
99 100