Git一直在从我的存储库中删除2个目录,我该如何解决这个问题呢?

时间:2009-06-04 20:11:00

标签: git version-control

我不希望有人解决我的问题,但我不太确定如何解决这个问题。如果我做“git status”,我会得到:

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    app/controllers/application.rb
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       modified:   app/views/main/index.html.erb
#       modified:   public/stylesheets/bandop.css
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       vendor/plugins/contacts/.gitignore
#       vendor/plugins/contacts/.gitmodules

但如果我做“git add”。然后“git status”,我得到:

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    app/controllers/application.rb
#       modified:   app/views/main/index.html.erb
#       modified:   public/stylesheets/bandop.css
#       new file:   vendor/plugins/blackbook
#       deleted:    vendor/plugins/blackbook/CHANGES.markdown
#       deleted:    vendor/plugins/blackbook/Manifest.txt
#       deleted:    vendor/plugins/blackbook/README.markdown
#       deleted:    vendor/plugins/blackbook/Rakefile
#       deleted:    vendor/plugins/blackbook/blackbook.gemspec
#       deleted:    vendor/plugins/blackbook/debug_blackbook.rb
#       deleted:    vendor/plugins/blackbook/init.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/exporter/base.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/exporter/vcf.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/exporter/xml.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/importer/aol.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/importer/base.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/importer/csv.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/importer/freenet.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/importer/gmail.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/importer/gmx.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/importer/hotmail.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/importer/page_scraper.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/importer/web.de.rb
#       deleted:    vendor/plugins/blackbook/lib/blackbook/importer/yahoo.rb
#       deleted:    vendor/plugins/blackbook/test/fixtures/aol_new_contacts.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/gmail.csv
#       deleted:    vendor/plugins/blackbook/test/fixtures/gmail_bad_login_response_stage_2.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/gmail_contacts.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/gmail_login_response_stage_1.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/gmail_login_response_stage_2.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/gmail_login_response_stage_2a.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/gmail_login_response_stage_3.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/gmail_redirect_body.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/hotmail_bad_login_response_stage_2.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/hotmail_contacts.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/hotmail_login_response_stage_1.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/hotmail_login_response_stage_2.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/hotmail_login_response_stage_3.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/hotmail_scrape_first_page.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/hotmail_scrape_response_stage_1.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/hotmail_scrape_response_stage_2.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/hotmail_scrape_response_stage_3.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/yahoo_bad_login_response_stage_2.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/yahoo_contacts.csv
#       deleted:    vendor/plugins/blackbook/test/fixtures/yahoo_contacts_not_logged_in.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/yahoo_contacts_stage_1.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/yahoo_login_response_stage_1.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/yahoo_login_response_stage_2.html
#       deleted:    vendor/plugins/blackbook/test/fixtures/yahoo_no_user_response_stage_2.html
#       deleted:    vendor/plugins/blackbook/test/freenet_importer_test.rb
#       deleted:    vendor/plugins/blackbook/test/gmx_importer_test.rb
#       deleted:    vendor/plugins/blackbook/test/scripts/live_test.rb
#       deleted:    vendor/plugins/blackbook/test/test_blackbook.rb
#       deleted:    vendor/plugins/blackbook/test/test_blackbook_exporter_base.rb
#       deleted:    vendor/plugins/blackbook/test/test_blackbook_exporter_vcf.rb
#       deleted:    vendor/plugins/blackbook/test/test_blackbook_exporter_xml.rb
#       deleted:    vendor/plugins/blackbook/test/test_blackbook_importer_aol.rb
#       deleted:    vendor/plugins/blackbook/test/test_blackbook_importer_base.rb
#       deleted:    vendor/plugins/blackbook/test/test_blackbook_importer_csv.rb
#       deleted:    vendor/plugins/blackbook/test/test_blackbook_importer_gmail.rb
#       deleted:    vendor/plugins/blackbook/test/test_blackbook_importer_hotmail.rb
#       deleted:    vendor/plugins/blackbook/test/test_blackbook_importer_page_scraper.rb
#       deleted:    vendor/plugins/blackbook/test/test_blackbook_importer_yahoo.rb
#       deleted:    vendor/plugins/blackbook/test/test_helper.rb
#       deleted:    vendor/plugins/blackbook/test/web.de_importer_test.rb
#       deleted:    vendor/plugins/blackbook/vendor/plugins/blackbook/lib/autotest/blackbook.rb
#       deleted:    vendor/plugins/blackbook/vendor/plugins/blackbook/lib/autotest/discover.rb
#       new file:   vendor/plugins/contacts
#       deleted:    vendor/plugins/contacts/MIT-LICENSE
#       deleted:    vendor/plugins/contacts/README.rdoc
#       deleted:    vendor/plugins/contacts/Rakefile
#       deleted:    vendor/plugins/contacts/lib/config/contacts.yml
#       deleted:    vendor/plugins/contacts/lib/contacts.rb
#       deleted:    vendor/plugins/contacts/lib/contacts/flickr.rb
#       deleted:    vendor/plugins/contacts/lib/contacts/google.rb
#       deleted:    vendor/plugins/contacts/lib/contacts/version.rb
#       deleted:    vendor/plugins/contacts/lib/contacts/windows_live.rb
#       deleted:    vendor/plugins/contacts/lib/contacts/yahoo.rb
#       deleted:    vendor/plugins/contacts/spec/contact_spec.rb
#       deleted:    vendor/plugins/contacts/spec/feeds/contacts.yml
#       deleted:    vendor/plugins/contacts/spec/feeds/flickr/auth.getFrob.xml
#       deleted:    vendor/plugins/contacts/spec/feeds/flickr/auth.getToken.xml
#       deleted:    vendor/plugins/contacts/spec/feeds/google-many.xml
#       deleted:    vendor/plugins/contacts/spec/feeds/google-single.xml
#       deleted:    vendor/plugins/contacts/spec/feeds/wl_contacts.xml
#       deleted:    vendor/plugins/contacts/spec/feeds/yh_contacts.txt
#       deleted:    vendor/plugins/contacts/spec/feeds/yh_credential.xml
#       deleted:    vendor/plugins/contacts/spec/flickr/auth_spec.rb
#       deleted:    vendor/plugins/contacts/spec/gmail/auth_spec.rb
#       deleted:    vendor/plugins/contacts/spec/gmail/fetching_spec.rb
#       deleted:    vendor/plugins/contacts/spec/rcov.opts
#       deleted:    vendor/plugins/contacts/spec/spec.opts
#       deleted:    vendor/plugins/contacts/spec/spec_helper.rb
#       deleted:    vendor/plugins/contacts/spec/windows_live/windows_live_spec.rb
#       deleted:    vendor/plugins/contacts/spec/yahoo/yahoo_spec.rb
#       deleted:    vendor/plugins/contacts/vendor/windowslivelogin.rb

问题是我从未删除任何这些文件,git只是认为我做了。我的解决方法是在每次提交之前每次都执行“git add vendor / plugins / contacts / ”和“git add vendor / plugins / blackbook / ”,但这很糟糕。任何人都可以就此提供方向吗?

更新:

感谢评论,我已经找到了大部分问题。我从未将我的插件视为子模块,即使它们是源控制的。

到目前为止,我已经从黑名单插件中删除了SCM(我实际上并不需要或想要它)。我完全删除了联系人并做了:

git submodule add repo_address local_address
git submodule init
git submodule update
git add vendor/plugins/contacts
git add .
git commit -m "submodule should be committing now"

但现在的问题是,虽然联系人插件代码存在于我的本地仓库中。我不能让它承诺我的远程回购。甚至在“git add”之后。或者更明确地说“git add vendor / plugins / contacts”....这里有什么想法吗?

谢谢!

2 个答案:

答案 0 :(得分:11)

怪异。您有blog entry报告完全相同的问题。使用子模块,如Dave's answer中所述。

  

这只能通过删除“restful_authentication”目录中的版本控制来解决:

.~/projects/bushi2do master $ rm -rf vendor/plugins/restful_authentication/.git
.~/projects/bushi2do master $ git add .
.~/projects/bushi2do master $ git status
# On branch master
nothing to commit (working directory clean)
  

此修复程序的缺点是您无法再对插件目录进行“git pull”以获取更新。


怎么样

git rm --cached vendor/plugins/contacts
git rm --cached vendor/plugins/blackbook

你是如何在你的插件目录中声明你的子模块的?

因为我记得经典的子模块捕获 如果您使用git子模块,如果foo是您的子模块,请不要git add foo/(注意斜杠!)。它变得凌乱。

来自here

在子模块上使用git add时,请确保没有拖尾斜杠。

> git add local/path
  -- adds the submodule

> git add local/path/
  -- adds all the files in the submodule directly into your repository, big no-no

答案 1 :(得分:1)

无法确切地告诉您,但我会查看问题是否与指定为git子模块的“blackbook”和“contacts”插件有关。