标题所说的一直对我有用,但是突然我修改的文件不再添加,为什么?
git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: ../../core/src/com/pixelscientists/galaxy/bullet/ContactHandler.java
modified: ../../core/src/com/pixelscientists/galaxy/bullet/MyContactListener.java
modified: ../../core/src/com/pixelscientists/galaxy/bullet/handler/ExplorableAreaVsPlayerHandler.java
modified: ../../core/src/com/pixelscientists/galaxy/bullet/handler/LazerShotVsAsteroidHandler.java
modified: ../../core/src/com/pixelscientists/galaxy/bullet/handler/PlayerVsPickupHandler.java
modified: ../../core/src/com/pixelscientists/galaxy/entity/impl/Asteroid.java
Untracked files:
(use "git add <file>..." to include in what will be committed)
textures/earth/
textures/europa2_out.jpg
textures/fog.jpg
textures/fog.png
textures/jupiter-transparent.png
textures/jupiter.jpg
textures/laser.png
no changes added to commit (use "git add" and/or "git commit -a")
git add -u
git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: ../../core/src/com/pixelscientists/galaxy/bullet/ContactHandler.java
modified: ../../core/src/com/pixelscientists/galaxy/bullet/MyContactListener.java
modified: ../../core/src/com/pixelscientists/galaxy/bullet/handler/ExplorableAreaVsPlayerHandler.java
modified: ../../core/src/com/pixelscientists/galaxy/bullet/handler/LazerShotVsAsteroidHandler.java
modified: ../../core/src/com/pixelscientists/galaxy/bullet/handler/PlayerVsPickupHandler.java
modified: ../../core/src/com/pixelscientists/galaxy/entity/impl/Asteroid.java
Untracked files:
(use "git add <file>..." to include in what will be committed)
textures/earth/
textures/europa2_out.jpg
textures/fog.jpg
textures/fog.png
textures/jupiter-transparent.png
textures/jupiter.jpg
textures/laser.png
no changes added to commit (use "git add" and/or "git commit -a")
有谁知道什么可能会导致这种行为?正如我所说,我之前已经这样做过几次,以避免添加大纹理图像。即使是 git add * 也仅添加纹理,而不添加我修改的源文件。这怎么可能?
最佳答案
如果您使用 git 2.0,那就可以了,正如我在“Difference between “ git add -A
” and “ git add .
””中提到的。
git add -u
现在(git 2.0,2014 年 5 月)可以在整个存储库上运行。
在 git 2.0 之前,您需要执行 git add -u ../..
在你的情况下。
参见 git add
:
If no
<pathspec>
is given when-u
option is used, all tracked files in the entire working tree are updated
(old versions of Git used to limit the update to the current directory and its subdirectories).
关于git add -u 不添加修改过的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24074954/