# "submodule" mistake and a problem

5 messages from 2012-10-01 to 2012-10-01. Participants: Howard Miller, Johannes Sixt, Jens Lehmann.
Thread: https://gitlist.dev/t/31700

## Howard Miller, 2012-10-01 10:41

Subject: "submodule" mistake and a problem
Message-ID: <CAHVO_92=5u-i+-d__5k7Uoq5pF4iACq9GuBSj4U5MepbKV_jdA@mail.gmail.com>
URL: https://gitlist.dev/e/CAHVO_92%3D5u-i%2B-d__5k7Uoq5pF4iACq9GuBSj4U5MepbKV_jdA%40mail.gmail.com

```
Hi,

I did this and now am confused/stuck...

- I have an existing (long standing) project in git with an upstream in github
- I added a subdirectory which I had forgotten was itself a git
project (i.e. it has its own .git directory)
- I committed the subdirectory (git add /path/to/subdir;  git commit -m ....)
- I pushed the latest version upstream

....at this point I realised that only the directory name had been pushed. SO...

- git rm /path/to/subdir resulted in fatal: pathspec
'/path/to/subdir/' did not match any files
- so I deleted it manually, re-copied the directory and removed its
.git directory

...I now cannot add or commit the directory. Git just ignores it. I
have grepped and searched and kind find no reference to this directory
anywhere. I am completely stumped.

Can anybody help? I don't want this to be a git subdirectory, I just
want to be able to add the files (without the .git directory)

Cheers :)

```

## Johannes Sixt, 2012-10-01 11:42

Subject: Re: "submodule" mistake and a problem
Message-ID: <506981C1.3030504@viscovery.net>
URL: https://gitlist.dev/e/506981C1.3030504%40viscovery.net
In-Reply-To: <CAHVO_92=5u-i+-d__5k7Uoq5pF4iACq9GuBSj4U5MepbKV_jdA@mail.gmail.com>

```
Am 10/1/2012 12:41, schrieb Howard Miller:
> - I have an existing (long standing) project in git with an upstream in github
> - I added a subdirectory which I had forgotten was itself a git
> project (i.e. it has its own .git directory)
> - I committed the subdirectory (git add /path/to/subdir;  git commit -m ....)
> - I pushed the latest version upstream
> 
> .....at this point I realised that only the directory name had been pushed. SO...
> 
> - git rm /path/to/subdir resulted in fatal: pathspec
> '/path/to/subdir/' did not match any files
> - so I deleted it manually, re-copied the directory and removed its
> ..git directory
> 
> ....I now cannot add or commit the directory. Git just ignores it. I
> have grepped and searched and kind find no reference to this directory
> anywhere. I am completely stumped.
> 
> Can anybody help? I don't want this to be a git subdirectory, I just
> want to be able to add the files (without the .git directory)

Perhaps:

  git rm -f --cached path/to/subdir   # remove from index, keep files
  git add path/to/subdir

-- Hannes

```

## Howard Miller, 2012-10-01 12:05

Subject: Re: "submodule" mistake and a problem
Message-ID: <CAHVO_93d92Ert35z1popk+X8HAAHX_jwTVdRCjrhNHrhTsvx2Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAHVO_93d92Ert35z1popk%2BX8HAAHX_jwTVdRCjrhNHrhTsvx2Q%40mail.gmail.com
In-Reply-To: <506981C1.3030504@viscovery.net>

```
>
> Perhaps:
>
>   git rm -f --cached path/to/subdir   # remove from index, keep files
>   git add path/to/subdir
>
> -- Hannes

Fantastic.... worked perfectly.  I'll write that down somewhere for
the next time I do it :)

Is there a better way of handling sub-modules like that? I've looked
at git submodules but just got into more of a mess. It would be nice
to push a project complete with a (git) submodule upstream but it
seems tricky or impossible.

Thanks :)

```

## Jens Lehmann, 2012-10-01 16:40

Subject: Re: "submodule" mistake and a problem
Message-ID: <5069C760.2020603@web.de>
URL: https://gitlist.dev/e/5069C760.2020603%40web.de
In-Reply-To: <CAHVO_93d92Ert35z1popk+X8HAAHX_jwTVdRCjrhNHrhTsvx2Q@mail.gmail.com>

```
Am 01.10.2012 14:05, schrieb Howard Miller:
>>
>> Perhaps:
>>
>>   git rm -f --cached path/to/subdir   # remove from index, keep files
>>   git add path/to/subdir
>>
>> -- Hannes
> 
> Fantastic.... worked perfectly.  I'll write that down somewhere for
> the next time I do it :)
> 
> Is there a better way of handling sub-modules like that? I've looked
> at git submodules but just got into more of a mess. It would be nice
> to push a project complete with a (git) submodule upstream but it
> seems tricky or impossible.

Git submodules are distinct repositories by design, so you'd have to
create an upstream repository for the submodule too to make that work.
But I have the impression that you want to import another repository
into a directory of your repo, so maybe git subtree is what you want.

```

## Howard Miller, 2012-10-01 21:16

Subject: Re: "submodule" mistake and a problem
Message-ID: <CAHVO_90pLFWb87mFfDpC1ZDQR=jm2YYFj597=kwVPTEv4AA+yg@mail.gmail.com>
URL: https://gitlist.dev/e/CAHVO_90pLFWb87mFfDpC1ZDQR%3Djm2YYFj597%3DkwVPTEv4AA%2Byg%40mail.gmail.com
In-Reply-To: <5069C760.2020603@web.de>

```
I was not aware of git subtree. I'll go and do some reading. Thanks
for the pointer!

On 1 October 2012 17:40, Jens Lehmann <Jens.Lehmann@web.de> wrote:
>
> Am 01.10.2012 14:05, schrieb Howard Miller:
> >>
> >> Perhaps:
> >>
> >>   git rm -f --cached path/to/subdir   # remove from index, keep files
> >>   git add path/to/subdir
> >>
> >> -- Hannes
> >
> > Fantastic.... worked perfectly.  I'll write that down somewhere for
> > the next time I do it :)
> >
> > Is there a better way of handling sub-modules like that? I've looked
> > at git submodules but just got into more of a mess. It would be nice
> > to push a project complete with a (git) submodule upstream but it
> > seems tricky or impossible.
>
> Git submodules are distinct repositories by design, so you'd have to
> create an upstream repository for the submodule too to make that work.
> But I have the impression that you want to import another repository
> into a directory of your repo, so maybe git subtree is what you want.

```
