Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git add not working with .png files?

Tags:

git

I have a dirty working tree, dirty because I made changes to source files and touched up some images. I was trying to add just the images to the index, so I ran this command:

git add *.png

But, this doesn't add the files. There were a few new image files that were added, but none of the ones that were modified/pre-existing were added.

What gives?

Edit: Here is some relevant terminal output

$ git status
# On branch master
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   src/main/java/net/plugins/analysis/FormMatcher.java
#   modified:   src/main/resources/icons/doctor_edit_male.png
#   modified:   src/main/resources/icons/doctor_female.png
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   src/main/resources/icons/arrow_up.png
#   src/main/resources/icons/bullet_arrow_down.png
#   src/main/resources/icons/bullet_arrow_up.png
no changes added to commit (use "git add" and/or "git commit -a")

Then executed "git add *.png" (no output after command)

Then:

$ git status
# On branch master
#
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   new file:   src/main/resources/icons/arrow_up.png
#   new file:   src/main/resources/icons/bullet_arrow_down.png
#   new file:   src/main/resources/icons/bullet_arrow_up.png
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   src/main/java/net/plugins/analysis/FormMatcher.java
#   modified:   src/main/resources/icons/doctor_edit_female.png
#   modified:   src/main/resources/icons/doctor_edit_male.png
like image 492
DLaw Avatar asked May 24 '10 19:05

DLaw


People also ask

Why is PNG not working?

Another possible reason is if the user is operating an outdated version of Windows 10 hence or the app, the default program might not support the file format. The latest versions of programs cannot open relatively old file formats. A version of Windows 10 has been attributed to why PNG files can't be opened.

How do I enable PNG?

Open the image you want to convert into PNG by clicking File > Open. Navigate to your image and then click “Open.” Once the file is open, click File > Save As. In the next window make sure you have PNG selected from the drop-down list of formats, and then click “Save.”


1 Answers

Michael Mrozek's comment is essentially the answer. *.png matches files of that name in the current directory, not in subdirectories. If you want to add ones in a subdirectory, do so:

git add src/main/resources/icons/*.png

Or, depending on your shell, you may be able to do:

git add **/*.png

The point is that it's the shell that does the globbing (expands *.png into a list of filenames). Git has nothing to do with that; it just takes the arguments the shell gives it.

Edit: Since this managed to get accepted, I should go ahead and point out as others did that some git commands do support globbing internally (via fnmatch), so if you quote a glob pattern, it'll be passed unmodified by the shell to git, where the globbing expansion will take place.

like image 80
Cascabel Avatar answered Sep 18 '22 13:09

Cascabel