2

I had Git a project with other Git project inside. I finally decided to remove the second one, so I removed the .git directory:

rm -rf /pathToProject/pathToProjectInsideProject/.git

But now, when I do git status I can't see the changes on the pathToProject/pathToProjectInsideProject/ directory.

I've try with:

git add pathToProjectInsideProject

but nothing changes. Any idea of how to include this directory to the main git repository?

Edit:

When I try to add a single file with force (git add --force pathToProjectInsideProject/file.php) I'm getting this error:

pathToProjectInsideProject/file.php is in submodule pathToProjectInsideProject

Edit2:

This question is duplicate: How do I add files in Git to the path of a former submodule?.

The solution is:

git rm --cached pathToProjectInsideProject
git add pathToProjectInsideProject
Community
  • 1
  • 1
Manolo
  • 24,020
  • 20
  • 85
  • 130
  • Did you try `git add --all` ? – Vinay Veluri Sep 04 '14 at 09:02
  • @VinayVeluri - Well, there are some files that I don't want to add. Just want to add all files and folders on the mentioned directory. – Manolo Sep 04 '14 at 09:03
  • Have you had submodules? – martin Sep 04 '14 at 09:05
  • @martin - That's it. Didn't know that term. – Manolo Sep 04 '14 at 09:06
  • your subdir Git is configured as a Git submodule. You have to remove this submodule if you want to add files from it (delete it from .gitmodules files) – pomeh Sep 04 '14 at 09:24
  • @pomeh - I don't find any `.gitmodules` file. I've just deleted the `.git` directory in `pathToProjectInsideProject`. – Manolo Sep 04 '14 at 09:28
  • if you have it, it's located at the same level as your top `.git` dir. If you don't have it, then you might have some `.gitignore` file somewhere with a rule to ignore that subdir – pomeh Sep 04 '14 at 09:29
  • @pomeh - Don't have it. Also tried `find ./ -name .gitignore` and just have one, and don't ingnore that subdirectory. – Manolo Sep 04 '14 at 09:32
  • you have it for sure, that's why you get the error `pathToProjectInsideProject/file.php is in submodule pathToProjectInsideProject`. Try to find it with `find /pathToProject/ -name ".git*"` or even `find /pathToProject/ -name ".gi*"` – pomeh Sep 04 '14 at 09:35
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/60604/discussion-between-manolo-and-pomeh). – Manolo Sep 04 '14 at 09:39

1 Answers1

0

There is a interactive way to add files using git shell.

git add -i

*** Commands ***
  1: status       2: update       3: revert       4: add untracked
  5: patch        6: diff         7: quit         8: help
What now> 4
  1: New Text Document.txt
  2: s/New Text Document.txt
Add untracked>>

So add the files if less in number. Or else use git commit tool which gives interactive UI.

EDIT:

* indicates the file is added to track

enter image description here

Vinay Veluri
  • 6,671
  • 5
  • 32
  • 56