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
195
votes
2 answers

Where does Git store the SHA1 of the commit for a submodule?

I know that when you add a submodule to a git repository it tracks a particular commit of that submodule referenced by its sha1. I'm trying to find where this sha1 value is stored. The .gitmodules and .git/config files only show the paths for the…
Abizern
  • 146,289
  • 39
  • 203
  • 257
194
votes
11 answers

How do I manage conflicts with git submodules?

I have a git superproject that references several submodules and I am trying to lock down a workflow for the rest of the my project members to work within. For this question, lets say my superproject is called supery and the submodule is called…
Tyler
  • 3,539
  • 3
  • 18
  • 14
194
votes
6 answers

Git: fatal: Pathspec is in submodule

I'm trying to get TravisCI to automatically deploy my Hakyll static site, according to this guide. Here's how my repo is set up. I have my source branch, which contains my hakyll and markdown files. It builds the html into the _site directory, which…
jmite
  • 8,171
  • 6
  • 40
  • 81
194
votes
10 answers

How to make shallow git submodules?

Is it possible to have shallow submodules? I have a superproject with several submodules, each with a long history, so it gets unnecessarily big dragging all that history. All I have found is this unanswered thread. Should I just hack git-submodule…
Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275
193
votes
23 answers

Git will not init/sync/update new submodules

Here's part of the contents of my .gitmodules file: [submodule "src/static_management"] path = src/static_management url = git://github.com/eykd/django-static-management.git [submodule "external/pyfacebook"] path =…
David Eyk
  • 12,171
  • 11
  • 63
  • 103
188
votes
12 answers

How to get rid of Git submodules untracked status?

I can't seem to get rid of untracked content in Git's submodules. Running git status yields: # On branch master # Changes not staged for commit: # (use "git add ..." to update what will be committed) # (use "git checkout -- ..." to discard…
Tomer Lichtash
  • 9,002
  • 16
  • 55
  • 71
181
votes
1 answer

How can I have linked dependencies in a git repo?

In my scripts, I often use libraries (mine or others') that have their own repos. I don't want to duplicate those in my repo and get stuck with updating them every time a new version comes out. However, when somebody clones the repo, it should…
Lea Verou
  • 23,618
  • 9
  • 46
  • 48
179
votes
1 answer

git submodule tracking latest

We are moving our (huge) project to git and we are thinking about using submodules. Our plan is to have three different heads in the superproject: release, stable, latest The project leads will handle the release and stable branches. They will…
l.thee.a
  • 3,231
  • 6
  • 25
  • 28
172
votes
7 answers

How to revert a Git Submodule pointer to the commit stored in the containing repository?

I have a git submodule in my main git repo. As I understand it, the main repo stores a SHA value (somewhere...), pointing to the specific commit of the submodule that it is "linked to". I went in to my submodule and typed git checkout…
Smashery
  • 57,848
  • 30
  • 97
  • 128
172
votes
2 answers

Git submodule inside of a submodule (nested submodules)

Is it possible for a git submodule to be made of several other git submodules, and the super git repo to fetch the contents for each submodule? I have tried to do this using the obvious/naive approach of creating a git repo holding several…
firstresponder
  • 5,000
  • 8
  • 32
  • 38
167
votes
3 answers

Git submodule push

If I modify a submodule, can I push the commit back to the submodule origin, or would that require a clone? If clone, can I store a clone inside another repository?
webjay
  • 5,358
  • 9
  • 45
  • 62
166
votes
15 answers

How to track untracked content?

See below the solid line for my original question. I have a folder in my local directory that is untracked. When I run git status, I get: Changed but not updated: modified: vendor/plugins/open_flash_chart_2 (modified content, untracked…
sscirrus
  • 55,407
  • 41
  • 135
  • 228
156
votes
9 answers

Git: can I suppress listing of 'modified content'/dirty submodule entries in status, diff, etc?

Somewhen (around the 1.6.x releases, I think) git became aware of changes inside submodules. That only serves to annoy me: $ git status vendor | grep modified: # modified: vendor/rails (modified content) $ git diff vendor/ diff --git…
kch
  • 77,385
  • 46
  • 136
  • 148
145
votes
9 answers

Convert a Git folder to a submodule retrospectively?

Quite often it is the case that you're writing a project of some kind, and after a while it becomes clear that some component of the project is actually useful as a standalone component (a library, perhaps). If you've had that idea from early on,…
naught101
  • 18,687
  • 19
  • 90
  • 138
141
votes
5 answers

How to change a git submodule to point to a subfolder?

Skimming through the SubModule tutorial, I created a submodule out of the boto project. Then, I discovered that I actually need only a subset of this project - specifically, the boto folder. I would like to change my submodule to point to this…
ripper234
  • 222,824
  • 274
  • 634
  • 905