当前位置:  开发笔记 > 编程语言 > 正文

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

如何解决《Git一直在从我的存储库中删除2个目录,我该如何解决这个问题呢?》经验,为你挑选了1个好方法。

我不指望有人能解决我的问题,但我不太确定如何解决这个问题.如果我做"git status",我得到:

# On branch master
# Changes to be committed:
#   (use "git reset HEAD ..." to unstage)
#
#       deleted:    app/controllers/application.rb
#
# Changed but not updated:
#   (use "git add ..." to update what will be committed)
#
#       modified:   app/views/main/index.html.erb
#       modified:   public/stylesheets/bandop.css
#
# Untracked files:
#   (use "git add ..." 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 ..." 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"....这里的任何想法?

谢谢!



1> VonC..:

奇怪的.您有一个博客条目报告完全相同的问题.使用子模块,如Dave的回答中所述.

这只能通过删除"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子模块,git add foo/如果foo是您的子模块,请不要这样做(观察尾部斜线!).它变得凌乱.

从这里:

在子模块上使用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

推荐阅读
手机用户2402851155
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有