views:

1368

answers:

3

This question is based on this thread.

My .gitmodules is at my Home

[submodule "bin"]
           path = bin
           url = git://github.com/masi/bin.git

My folder -structure at my Home:

~
|-- [drwxr-xr-x] bin          // this is the folder which I make a submodule
                              // it is also a folder where I have a Git to push my submodule's files
    | -- fileA
    ` -- folderA
    ...

I run

git submodule init    # I get no output from these commands
git submodule update

I run

git submodule foreach git pull

I get

Entering 'bin'
fatal: Where do you want to fetch from today?
Stopping at 'bin'; script returned non-zero status.

My first assumption to fix the bug was to change path = bin to path = /Users/Masi/bin. However, this does not solve the problem.

How can you upload the content from the external repository which is a submodule in my Git?

+2  A: 

This is normally the error made when there is no remote configured.
(From this thread)

It was a patch introduced to at least fixes the regression when running "git pull" in a repository initialized long time ago that does not use the .git/config file to specify where my remote repositories are.

a better message would probably be something like:

No default remote is configured for your current branch,
and the default remote "origin" is not configured either.

I think the message missed being made user-friendly in earlier passes due to being inaccessible at the time.


So this message indicates the remote repo mentioned in .git/modules is not declared in .git/config

From git submodule

Submodules are not to be confused with remotes, which are meant mainly for branches of the same project;
submodules are meant for different projects you would like to make part of your source tree, while the history of the two projects still stays completely independent and you cannot modify the contents of the submodule from within the main project.

I believe you may have missed the step of git submodule init:

submodule init

Initialize the submodules, i.e. register each submodule name and url found in .gitmodules into .git/config.
The key used in .git/config is submodule.$name.url.
This command does not alter existing information in .git/config.
You can then customize the submodule clone URLs in .git/config for your local setup and proceed to git submodule update; you can also just use git submodule update --init without the explicit init step if you do not intend to customize any submodule locations.

If your remote repo (declared in .git/modules) is adequately referenced in .git/config, you should not have this error message anymore.

Before using (pullin) submodules, the steps:

git submodule init
git submodule update

remain necessary.

VonC
I run those steps - I clarify my question.
Masi
In other words, the same problem occurs with the commands too.
Masi
A: 

What does the .git/config look like for your bin submodule?

My .git/config

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
[remote "github"]
    url = [email protected]:masi/Sam.git
    fetch = +refs/heads/*:refs/remotes/github/*
[submodule "bin"]
    url = git://github.com/masi/bin.git
Masi
A: 

I removed the submodule -part in my .git/config.

I run

~ master* $ git submodule init                      #this adds it back to .git/config
Submodule 'bin' (git://github.com/masi/bin.git) registered for path 'bin'
~ master* $ git submodule update 
~ master* $ git submodule foreach git pull
Entering 'bin'
fatal: Where do you want to fetch from today?
Stopping at 'bin'; script returned non-zero status.
~ master* $

The same problem persists.

Masi
You did removed your `[submodule "bin"]` section from your .git/config of your bin repo: good. But do you have a `[submodule "bin"]` section in your main "Masi" repo? (the one which has to load the bin submodule). That is what the `git submodule init` is supposed to do...
VonC
I did not remove `[submodule "bin"] section from my .git/config of my `bin` repo, since I did not have it there. I do have `[submodule "bin"]` section in my "Masi" repo, the one which has to load the bin submodule. --- The problem still persists when the folder name `bin` is the same as the name of my submodule `bin`.
Masi