Git添加不能使用.png文件? [英] Git add not working with .png files?
问题描述
我有一个肮脏的工作树,因为我对源文件进行了更改并修改了一些图像,所以很脏。我试图添加图像到索引,所以我跑这个命令:
git add * .png
但是,这不会添加文件。添加了一些新的图像文件,但没有添加任何已修改/已存在的图像文件。
?
编辑:以下是一些相关的终端输出:
$ git status
#分支主
#
#已更改但未更新:
#(使用git add< file> ...更新将提交的内容)
#(使用git checkout - < file> ...放弃工作目录中的更改)
#
#修改: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
#
#未记录的文件:
#(使用git add< file> ...来包含将要提交的内容)
#
#src / main / resources /icons/arrow_up.png
#src / main / resources /图标/ bullet_arrow_down.png
#src / main / resources /图标/ bullet_arrow_up.png
没有更改添加到通讯它(使用git add和/或git commit -a)
然后执行git添加* .png(命令后没有输出)
然后:
$ git status
#在分支主机上
#
#要提交的更改:
#(使用git reset HEAD< file> ...
#
#新文件:src / main / resources / icons / arrow_up.png
#新文件:src / main / resources /图标/ bullet_arrow_down.png
#新文件:src / main / resources / icons / bullet_arrow_up.png
#
#已更改但未更新:
#(使用git add< file> ...来更新提交)
#(使用git checkout - < file> ...放弃工作目录中的更改)
#
#修改:src / main / java / net / plugins $ / $ c $ / code>
git add src / main / resources / icons / *。png
或者,根据您的shell,您可能会这样做:
git add ** / *。png
关键在于它是通过shell进行匹配(将* .png扩展为文件名列表)。 Git与此无关;它只需要shell提供的参数。
编辑:由于这个设法得到了接受,我应该继续并指出其他一些git命令支持的做法(通过fnmatch),所以如果你引用一个glob模式,它会被shell不加修改地传递给git,在那里进行globbing扩展。
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
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.
这篇关于Git添加不能使用.png文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!