【发布时间】:2015-09-02 14:48:40
【问题描述】:
假设我有一个 git 根文件夹 mine_git,其中有一个子目录 subdir。所以我工作了一点,我在subdir - git status 列出了所有更改的文件:
subdir$ git status -uno
# On branch master
# ...
#
# modified: mysubdirfile.txt
# modified: ../a-main-file.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
K,所以我想将所有这些跟踪和修改的文件添加到暂存区(或缓存?索引?不确定名称),以便之后我可以提交;所以我发出:
subdir$ git add -u
...然后我再次检查:
subdir$ git status -uno
# On branch master
# Changes to be committed:
# ...
#
# modified: mysubdirfile.txt
#
# Changes not staged for commit:
# ...
#
# modified: ../a-main-file.txt
#
# Untracked files not listed (use -u option to show untracked files)
所以,只有我当前位置下的那些文件是 git added,而 不是 那些在父/兄弟文件夹中的文件 - 即使这些文件被这个 git 存储库跟踪,并显示在 @ 987654329@!
然后我通常必须手动复制粘贴文件名,以便做到git add ../a-main-file.txt。显然这很痛苦 - 那么是否有一些命令会添加 git status -uno 列出的 所有 文件,无论它们是否位于当前级别以下?
【问题讨论】:
-
git add -u在这里工作正常 -
谢谢@maggick - 正如下面的答案所指出的,它对我不起作用,因为我有一个旧版本的 git;干杯!