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
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.
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.”
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With