可以说我有一个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")
Run Code Online (Sandbox Code Playgroud)
K,所以我想将所有这些跟踪和修改的文件添加到临时区域(或缓存?索引?不确定名称),所以我可以事后提交; 所以我发出:
subdir$ git add -u
Run Code Online (Sandbox Code Playgroud)
......然后我再次检查:
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)
Run Code Online (Sandbox Code Playgroud)
因此,只有我当前位置下的那些文件被git add编辑,而不是父/兄弟文件夹中的文件 - 即使这些文件被这个git存储库跟踪,并显示在git status!
然后我通常必须手动复制粘贴文件名,以便做到git add ../a-main-file.txt.显然这是一个痛苦 - 所以有一些命令将添加列出的所有文件git status -uno,无论它们是否位于当前级别之下?
最新版本的git(2.4.3)应该已经这样做了.来自man 1 git-add:
-u, --update
Update the index just where it already has an entry matching <pathspec>.
This removes as well as modifies index entries to match the working tree,
but adds no new files.
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).
Run Code Online (Sandbox Code Playgroud)
那就是说,你可以尝试类似的东西git add -u -- ../relative/path/to/project/root.我没有方便的旧git版本,所以我无法测试它.
| 归档时间: |
|
| 查看次数: |
1712 次 |
| 最近记录: |