# Git tries to delete when doing git add

**URL:** <https://www.ruby-forum.com/t/git-tries-to-delete-when-doing-git-add/142503>\
**Category:** Rails\
**Created:** [July 8, 2008, 5:04pm UTC](https://www.ruby-forum.com/t/git-tries-to-delete-when-doing-git-add/142503 "2008-07-08T17:04:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![asoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/58956e/32.png) [@asoto](https://www.ruby-forum.com/u/asoto)\
**Post date:** [July 8, 2008, 5:04pm UTC](https://www.ruby-forum.com/t/git-tries-to-delete-when-doing-git-add/142503/1 "2008-07-08T17:04:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![asoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/58956e/32.png) [@asoto](https://www.ruby-forum.com/u/asoto)\
**Post date:** [July 8, 2008, 5:43pm UTC](https://www.ruby-forum.com/t/git-tries-to-delete-when-doing-git-add/142503/2 "2008-07-08T17:43:25Z")

</div>

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

On Jul 8, 10:04 am, Alex S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![asoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/58956e/32.png) [@asoto](https://www.ruby-forum.com/u/asoto)\
**Post date:** [July 8, 2008, 5:46pm UTC](https://www.ruby-forum.com/t/git-tries-to-delete-when-doing-git-add/142503/3 "2008-07-08T17:46:05Z")

</div>

I’m running version 1.5.5.

---

<div class="post-metadata">

**Author:** ![asoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/58956e/32.png) [@asoto](https://www.ruby-forum.com/u/asoto)\
**Post date:** [July 8, 2008, 6:48pm UTC](https://www.ruby-forum.com/t/git-tries-to-delete-when-doing-git-add/142503/4 "2008-07-08T18:48:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![asoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/58956e/32.png) [@asoto](https://www.ruby-forum.com/u/asoto)\
**Post date:** [July 8, 2008, 5:48pm UTC](https://www.ruby-forum.com/t/git-tries-to-delete-when-doing-git-add/142503/5 "2008-07-08T17:48:42Z")

</div>

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

On Jul 8, 10:46 am, Alex S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![asoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/58956e/32.png) [@asoto](https://www.ruby-forum.com/u/asoto)\
**Post date:** [July 9, 2008, 12:12am UTC](https://www.ruby-forum.com/t/git-tries-to-delete-when-doing-git-add/142503/6 "2008-07-09T00:12:12Z")

</div>

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

On Jul 8, 6:48 am, Alex S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![asoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/58956e/32.png) [@asoto](https://www.ruby-forum.com/u/asoto)\
**Post date:** [July 10, 2008, 3:06pm UTC](https://www.ruby-forum.com/t/git-tries-to-delete-when-doing-git-add/142503/7 "2008-07-10T15:06:51Z")

</div>

On Jul 8, 5:27 pm, DrMark [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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.

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](http://github.com/mdalessio/git-rake/tree/master)

HTH,  
-m
