git add -u 不添加修改过的文件

标签 git

标题所说的一直对我有用,但是突然我修改的文件不再添加,为什么?

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/

相关文章:

git - 即使我清除缓存,.gitignore 也无法正常工作

git - 这是做什么的 : git branch -f

混帐 : Push to different remote branch

Git fetch 说 "success"但没有下载任何东西

git - 没有 -a 选项的 git commit 有什么影响?

git - 调用mergetool后 merge 冲突自动消失

git - 如何判断我的 git repo 是否有冲突?

Git fork /merge 冲突?

node.js - 如何保留对 NPM 模块所做的本地更改?

git - Coda 2 和 github 设置 : cannot clone and connect to repository