添加文件夹中的某些文件

时间:2018-05-29 21:11:54

标签: git

我有一个包含10个文件的文件夹temp/,但我需要git add只有三个文件。除了添加temp/然后为不必要的文件执行git reset之外,最简单的方法是什么?

bash-3.2$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    temp/

2 个答案:

答案 0 :(得分:1)

只需列出它们。 感谢torek提醒我们-u

$: git status -u
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    x/0
    x/1
    x/2
    x/3
    x/4
    x/5
    x/6
    x/7
    x/8
    x/9


$: git add x/3 x/5 x/7
$: git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   x/3
    new file:   x/5
    new file:   x/7

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    x/0
    x/1
    x/2
    x/4
    x/6
    x/8
    x/9

答案 1 :(得分:1)

对于您的问题,我建议您尝试tig,在图片的status view上,您可以轻松选择要上演的文件。