Git tries to delete when doing git add .

Sorry, I know this is a git post, but I don't really know where else to
post this besides the official git mailing list, and I don't want to
post it there, because something this obvious surely can't be a bug.

Here's the problem, and it happens with almost all of my rails apps. I'm
developing my app, and I've got your standard plugins in vendor/plugins,
either as submodules or just cloned it (it doesn't matter, I get this
behavior either way). So lets say I create a new model with
script/generate scaffold Post. As you know, this generates about ten new
files in about 8 different directories. So instead of doing git add for
each one, I tried git add . However, when I do this, and then run git
status, git wants to delete some of my plugins, if not all of them.

Has anyone experienced/heard about this or a similar problem? It's
driving me crazy and there's no way this is a bug in the git core.
Thanks in advance.

What version of git are you running? I've personally never run into
anything like this.

I can't really help you right now, but if I can get some spare time
tonight at home I'll do some experimenting.

I seemed to have fixed the problem git deleting the .git/ directory in
the project and creating a new one. Maybe this problem was caused by
adding plugins in initially by cloning them instead of using submodules.
On that point, submodules is the way to handle plugins, correct?

Actually, I have completely stopped using submodules due to issues
when changing between Git branches. Some of my branches have different
versions of plugins and submodules were constantly an issue. I also
don't like that the main Git repository doesn't show changes to the
submodules (since they are separate repos). Sometimes changes in the
submodules impact the main app and I like to track that in one place.

I have a simple solution that is working well for us. My work flow is
like this:
I keep a directory named git-plugins which contains all of my git
repositories for my plugins. I make any modifications to a plugin
directly in the git-plugins folder. When finished making changes, I
delete the folder contents in the main app from vendor/plugins (not
the entire folder) and copy the contents from the relevant git-plugins
folder. (Make certain that you delete then copy. This removes any old
files.)

Here is an example:
Take a plugin called 'myplugin'. I store this in git-plugins/myplugin.
I make changes directly to the git-plugins/myplugin folder. When I
want to update my app, I delete the contents from vendor/plugins/
myplugin. I then copy git-plugins/myplugin/* to vendor/plugins/
myplugin.

I have turned this into a short script which automatically updates all
of my plugins with one command. This isn't as easy as using Piston was
with SVN but it works very smoothly. It also ensures that your main
Git log tracks changes to your app and all plugins.

Best of luck!

DrMark

You might be interested in git.rake, which solves most (all?) of the
common problems people (or at least me) have with managing multiple
git submodules.

The code is hosted on github: http://github.com/mdalessio/git-rake/tree/master

HTH,
-m