Filip Huysmans
Filip Huysmans

Reputation: 1341

Haunted image in git

I have uploaded new images in my project solution. They are committed and pushed to my bitbucket repository.

Now each time after I commit local changes (totally unrelated to the previously uploaded images) I'm getting git errors when i either want to pull or push:

enter image description here

I'm stuck as I can't push or pull and all my local changes are already committed.

How come it keeps getting errors on these already pushed image files?

I tried removing and readding the image, renaming the image recommitting but I still end up with this error.

I haven't had these errors before and I'm already working years in the same environment..

Thanks in advance!

EDIT

output git status:

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

Upvotes: 2

Views: 246

Answers (1)

Jan Hudec
Jan Hudec

Reputation: 76236

Git has this unique feature where you assemble the content of the commit incrementally. Unfortunately they couldn't even agree on a name, so it is referred to alternately as ‘stage’, ‘index’ and ‘cache’. That's where files are added with the git add command.

The IDEA Git plugin is trying to hide it from you, because it adds complexity, and because the UI, designed originally for other version control systems, does not have a good way to show it. But your working directory is in a state that requires you to deal with it.

The standard Git GUI (just run git gui in your work tree from the command-line) is quite good way to access all the features of the commit creation, or you can use one of the other GUIs that have the corresponding dialog (e.g. git extensions). If my memory serves me well the IDEA plugin does not have it though, so you'll need something beyond that.

Now what is your problem: It seems you've added the images to commit, and when Git complained about conflict in them on pull, just removed them from disk. But as they were already “added to version control”, that is ‘staged’ in Git lingo, Git still remembers them and has even bigger problem with them now. You can either

  • Open the git gui and chase them away from the lower left window by clicking on the icons (files are staged and unstaged in Git GUI by clicking on their icons, while clicking on their names shows the changes (for text files); it is quick and simple, but not discoverable at all).
  • From command-line do git reset HEAD design/img/interesses/neigborhood/ (as the status output suggests in attempt for being helpful, which fails due to the unfamiliar term ‘unstage’)

You have one more file staged, application/helpers/datetime_helper.php, so you have to commit it (or reset like the icons if that's not what you meant) before doing pull, because Git refuses to merge when there are local changes. That is actually important safety feature, since you can abort and retry the merge if you make a mistake in it that way. You probably have to pull before you push too, because there are other changes in the main repository.

Upvotes: 1

Related Questions