1

I'm trying to add files to a git repo that were somehow previously added as a submodule. I don't know how that happened.

I cannot find a .gitmodules file anywhere and my .git/config looks like this:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = [email protected]:frankV/dotfiles.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

I need to include the directory for vim vundle but I can't due to the issues stated above. To this point I have been unable to remove it from this repo or add any files below the directory for vundle.

When I try to add a file I get: fatal: Path '_vim/bundle/vundle/autoload/vundle' is in submodule '_vim/bundle/vundle'

and my git status output:

...
#   modified:   _vim/bundle/Command-T (untracked content)
#   modified:   _vim/bundle/The-NERD-Commenter (untracked content)
#   modified:   _vim/bundle/The-NERD-tree (untracked content)
#   modified:   _vim/bundle/matchit.zip (untracked content)
...

As you can see vundle is not in this list and it's fine to not track these submodules as they install via vundle... all the more reason however to get vundle working!

4
  • have you searched for .git folders or .gitmodules files inside of that bundle folder? It might be a nested repo somewhere Commented Mar 10, 2013 at 12:48
  • I did... didn't find anything. Don't know if it was there once and somehow got removed or what. Commented Mar 10, 2013 at 12:50
  • how did you search for them? if you used a filemanager, it might be hiding "dotfiles". Commented Mar 10, 2013 at 14:06
  • in terminal ls -a, I'm assuming .gitmodules would be in dotfiles/ and to clarify, the plugins [submodules] listed under git status have a .git directory. Vundle is the only one without one. Commented Mar 10, 2013 at 15:43

1 Answer 1

2

You have a nested repository, find it with find . -name .git, if you really want to import historyless source you can then git rm its containing directory and remove the .git directory itself. To not lose current history you could fetch from it and subtree-merge the branches, but the sweet spot in terms of preserving structure and history with minimum effort is going to be just keeping the repo structure as it is.

Git calls nested repositories submodules, and does have a command to help you manage the gruntwork --- for instance, submodules' primary repos are often hosted by third parties (yours at git://github.com/gmarik/vundle.git for instance), so the submodule command sets up some infrastructure to help advertise where any of your repo's clients can find the submodules' primaries --- but everything the submodule command does is assistance with mundane tasks like that. No other git command has any clue whether a repo is being used as a submodule or not, because it doesn't have to care.

So what it appears you're doing is trying to use the results of someone else's ongoing project as a building block in your own project, and the git way to do that is do simply do it in the most direct way possible: clone their project and use it as part of your own. This other answer I wrote might be TMI, it's about splitting a project into submodules, but it is another take on just how simple and direct the concept is.

Sign up to request clarification or add additional context in comments.

1 Comment

"but the sweet spot in terms of preserving structure and history with minimum effort is going to be just keeping the repo structure as it is." Sold! Thanks for the tip.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.