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
70
votes
3 answers

No submodule mapping found in .gitmodules for path and missing .gitmodules file

When I run git submodule init, I get the following error: No submodule mapping found in .gitmodules for path 'xxx' I searched for a .gitmodules file and I cannot find it anywhere. I have read this most popular SO question on the same topic. But…
Kim Stacks
  • 10,202
  • 35
  • 151
  • 282
69
votes
3 answers

How to checkout old git commit including all submodules recursively?

I have a git repo with multiple submodules. One of those submodules has multiple submodules of it's own. All I'm looking to do is check out an old commit on the master repo and have it checkout the appropriate commits from all submodules to get the…
Ben Baron
  • 14,496
  • 12
  • 55
  • 65
66
votes
3 answers

'git submodule update --init --recursive' VS 'git submodule foreach --recursive git submodule update --init'

I have git repo which has nested submodules. What is the difference between below 2 commands? git submodule update --init --recursive git submodule foreach --recursive git submodule update --init
Manish
  • 713
  • 1
  • 5
  • 10
65
votes
9 answers

Git submodule URL not including username?

I have a git repository set up with several submodules, which creates a .gitmodules file that is a tracked file in the parent repository. However, there are other developers wanting to work on this repository, and check out the submodules. But…
MidnightLightning
  • 6,715
  • 5
  • 44
  • 68
65
votes
10 answers

How to fix "modified content, untracked content" in git?

The objective is to commit a git branch. The output of "git status" for the branch is: On branch zeromq_new Your branch is up to date with 'origin/zeromq'. Changes not staged for commit: (use "git add ..." to update what will be committed) …
Ayush
  • 880
  • 1
  • 9
  • 21
65
votes
8 answers

Unable to find current origin/master revision in submodule path

In my project (which uses git), I need to use a library, which is still in progress. I decided to create a submodule for that library, because I want to update from time to time its latest version (I don't plan to make my own change there). I…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
64
votes
1 answer

Using someone else's repo as a Git Submodule on GitHub

I am trying to find out if it is possible to use someone else's repository (or branch of a repository) as a Submodule in your own Git repository. Documentation on github itself is either missing, or I'm not using the right terminology to look for…
Graham Conzett
  • 8,344
  • 11
  • 55
  • 94
64
votes
1 answer

What goes wrong when using git worktree with git submodules

I recently discovered the git worktree command: The new working directory is linked to the current repository, sharing everything except working directory specific files such as HEAD, index, etc. But the docs also indicate … the support for…
Joachim Breitner
  • 25,395
  • 6
  • 78
  • 139
63
votes
5 answers

How do I git clone --recursive and checkout master on all submodules in a single line?

I really like this command to fetch a repo with submodules: git clone git@github.com:my_user/my_repo.git --recursive However, the submodules are all set to "no branch" when they arrive, and I have to manually checkout master on each and every one. …
tedsuo
  • 3,943
  • 3
  • 17
  • 8
63
votes
3 answers

How can I add a specific folder from a git repo as a git submodule?

I have a git repo and I want to add a submodule to it. Problem is, the submodule exists as a folder inside another repo. Can I add only that folder as a submodule?
tuxcanfly
  • 2,494
  • 1
  • 20
  • 18
62
votes
8 answers

How to "resolve fatal: Not a git repository"?

I was trying to remove one sub-module from the project Tried rm -rf .git/modules/submodulePath After that I am having the issue fatal: Not a git repository
coreDeviOS
  • 1,468
  • 2
  • 14
  • 27
62
votes
13 answers

Git Submodule - Permission Denied

I am not able to clone the submodule existing within my private git repository. I do have access to entire repository, Have used the below commands but dint work, please help. What is the right way to clone the submodules in an existing repository?…
Max
  • 5,380
  • 6
  • 42
  • 66
61
votes
8 answers

Fatal Error when updating submodule using GIT

I am trying to update the submodules of this git repositary but I keep getting a fatal errors: [root@iptlock ProdigyView]# git submodule update --recursive Cloning into core... Permission denied (publickey). fatal: The remote end hung up…
Devin Dixon
  • 11,553
  • 24
  • 86
  • 167
61
votes
4 answers

.gitignore files added inside Git submodules

I recently reorganized my dotfiles to live inside a Git repository at ~/Dropbox/dotfiles and I'm using pathogen to bundle all Vim addons inside ~/Dropbox/dotfiles/home/.vim/bundle. These addons were added as Git submodules. Now the problem is, when…
rubiii
  • 6,903
  • 2
  • 38
  • 51
60
votes
2 answers

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

I been happily using submodules to track all the libraries my project depends from. The thing is I'm using a library called core-plot that only has a public mercurial repository. I can probably mirror it in a readonly Git repository, but is this…
dvicino
  • 1,469
  • 1
  • 11
  • 19