5

In an effort to debug a problem in a third party library, I copied their source into my own git repo. I reproduced the problem immediately so wanted to commit to record a starting point. When I attempted to commit, none of the files I had copied were showing up in my working tree, so I couldn't stage them.

I tried explicitly staging one of the files in the copied source:

git add README 
fatal: Path 'Src/Foo/README' is in submodule 'Src/Foo/FooBar'

So it seems git thinks it's a submodule, even though I never told it that it was. I tried deleting the .git directory in the root of the third party source, but that didn't help. Then I tried following these instructions, but it tells me I have no submodules:

git submodule deinit .
No submodule mapping found in .gitmodules for path 'Src/Foo/FooBar'

Any ideas?

Community
  • 1
  • 1
me--
  • 1,978
  • 1
  • 22
  • 42

1 Answers1

7

The simplest solution is to clone that third-party repo, reproduces your fix, commit and push (if you have access to their repo, you if you have forked it on GitHub)

If not, do (in a fresh clone of your repo) a:

git ls-tree HEAD Src/Foo/FooBar

See if there is an special entry 160000, which would indicate that FooBar was registered as a submodule at one point in time) even if the .gitmodules doesn't list FooBar anymore.

A git rm --cached Src/Foo/FooBar (with git 1.8.5+) would take care of that submodule entry.


Of course, if the thirdparty sources are not part of a git repo, then adding them in a different folder within your own repo would work too.
But the history of those third-party library files would become mixed with the history of your main repo.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. I already have modified the 3rd party source under my repo. I don't want a secondary repo - I want everything in the one spot. Tried doing the git rm and it just removed the directory from git. It then allowed me to add the directory back in, but not the contents (just like before). However, I did find a workaround (see my answer). – me-- Mar 08 '14 at 07:48
  • @me-- with declaring your thirdparty as submodule, you would keep everything in one spot. – VonC Mar 08 '14 at 07:48
  • understood. I guess I don't want the complication right now because I'm a git novice and because this is a short-term hack for a 3rd party library that I'll remove as soon as it is fixed in the official release binaries. Probably seems a silly approach to a git pro, but there you go. – me-- Mar 08 '14 at 08:09