git中的鬼影

时间:2019-05-22 11:18:03

标签: git version-control bitbucket

我在项目解决方案中上传了新图像。 它们已提交并推送到我的bitbucket存储库。

现在,每次我提交本地更改(与先前上传的图像完全无关)后,当我要拉动或推入时,都会收到git错误:

enter image description here

由于无法进行推拉操作而卡住了,所有本地更改都已提交。

为什么这些已推送的图像文件不断出现错误?

我尝试删除并读取图像,重新命名图像,然后重新提交,但是仍然出现此错误。

我以前没有这些错误,并且我已经在同一环境中工作了数年。

谢谢!

编辑

输出git状态:

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   application/helpers/datetime_helper.php
        new file:   design/img/interesses/neigborhood/borrow_items.svg
        new file:   design/img/interesses/neigborhood/care_job.svg
        new file:   design/img/interesses/neigborhood/childcare.svg
        new file:   design/img/interesses/neigborhood/coffee_chats.svg
        new file:   design/img/interesses/neigborhood/crea_and_manual_work.svg
        new file:   design/img/interesses/neigborhood/culture_trip.svg
        new file:   design/img/interesses/neigborhood/cycling.svg
        new file:   design/img/interesses/neigborhood/day_trip.svg
        new file:   design/img/interesses/neigborhood/game_or_cards.svg
        new file:   design/img/interesses/neigborhood/garden_job.svg
        new file:   design/img/interesses/neigborhood/gardening_together.svg
        new file:   design/img/interesses/neigborhood/groceries.svg
        new file:   design/img/interesses/neigborhood/it_job.svg
        new file:   design/img/interesses/neigborhood/make_music.svg
        new file:   design/img/interesses/neigborhood/neighbor_party.svg
        new file:   design/img/interesses/neigborhood/neighborhood_project.svg
        new file:   design/img/interesses/neigborhood/other_sports.svg
        new file:   design/img/interesses/neigborhood/pet_sitters.svg
        new file:   design/img/interesses/neigborhood/practical_job.svg
        new file:   design/img/interesses/neigborhood/receive_mail.svg
        new file:   design/img/interesses/neigborhood/teaching.svg
        new file:   design/img/interesses/neigborhood/technical_job.svg
        new file:   design/img/interesses/neigborhood/transport.svg
        new file:   design/img/interesses/neigborhood/walking.svg

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        deleted:    design/img/interesses/neigborhood/borrow_items.svg
        deleted:    design/img/interesses/neigborhood/care_job.svg
        deleted:    design/img/interesses/neigborhood/childcare.svg
        deleted:    design/img/interesses/neigborhood/coffee_chats.svg
        deleted:    design/img/interesses/neigborhood/crea_and_manual_work.svg
        deleted:    design/img/interesses/neigborhood/culture_trip.svg
        deleted:    design/img/interesses/neigborhood/cycling.svg
        deleted:    design/img/interesses/neigborhood/day_trip.svg
        deleted:    design/img/interesses/neigborhood/game_or_cards.svg
        deleted:    design/img/interesses/neigborhood/garden_job.svg
        deleted:    design/img/interesses/neigborhood/gardening_together.svg
        deleted:    design/img/interesses/neigborhood/groceries.svg
        deleted:    design/img/interesses/neigborhood/it_job.svg
        deleted:    design/img/interesses/neigborhood/make_music.svg
        deleted:    design/img/interesses/neigborhood/neighbor_party.svg
        deleted:    design/img/interesses/neigborhood/neighborhood_project.svg
        deleted:    design/img/interesses/neigborhood/other_sports.svg
        deleted:    design/img/interesses/neigborhood/pet_sitters.svg
        deleted:    design/img/interesses/neigborhood/practical_job.svg
        deleted:    design/img/interesses/neigborhood/receive_mail.svg
        deleted:    design/img/interesses/neigborhood/teaching.svg
        deleted:    design/img/interesses/neigborhood/technical_job.svg
        deleted:    design/img/interesses/neigborhood/transport.svg
        deleted:    design/img/interesses/neigborhood/walking.svg

1 个答案:

答案 0 :(得分:1)

Git具有此独特功能,您可以在其中递增地组合提交的内容。不幸的是,他们甚至无法同意一个名称,因此将其交替称为“阶段”,“索引”和“缓存”。就是使用git add命令添加文件的地方。

IDEA Git插件正试图向您隐藏它,因为它增加了复杂性,并且因为最初为其他版本控制系统设计的UI没有很好的显示方式。但是您的工作目录处于需要您处理的状态。

标准的Git GUI(只需从命令行在工作树中运行git gui即可访问提交创建的所有功能,或者您可以使用具有以下功能的其他GUI之一:相应的对话框(例如git扩展名)。如果我的记忆力很好,IDEA插件却没有,所以您还需要其他东西。

现在是什么问题:看来您已经添加了要提交的图像,当Git抱怨在拉动它们时发生冲突时,只需将它们从磁盘上删除即可。但是,由于它们已经“添加到版本控制中”(在Git术语中是“上演”的),因此Git仍然记得它们,并且现在对它们有更大的问题。您可以

  • 打开git gui并通过单击图标将它们从左下方窗口中移开(在Git GUI中,通过单击图标将文件暂存和取消暂存,而单击文件名则显示更改(对于文本文件);它既快速又简单,但根本无法发现)。
  • 在命令行中执行git reset HEAD design/img/interesses/neigborhood/(因为状态输出表明试图提供帮助,由于不熟悉的“ unstage”一词而失败)

您还有一个暂存的文件application/helpers/datetime_helper.php,因此在进行拉取之前,您必须提交该文件(如果不是您想要的意思,请像图标一样重设),因为在发生本地更改时Git拒绝合并。这实际上是重要的安全功能,因为如果您以这种方式出错,则可以中止并重试合并。您可能还必须先拉动,因为主存储库中还有其他更改。