Git跟踪未跟踪的文件而不添加提交

use*_*633 0 git version-control git-reset git-stage git-untracked

我运行了“ git reset”命令,但是我的未暂存更改已放入文件夹中。运行git status后,我得到如下内容:

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:   file1
    modified:   file2
    modified:   file3
    modified:   file4
    modified:   file5

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

    folder1
    folder2
    folder3
    folder4
Run Code Online (Sandbox Code Playgroud)

每个文件夹都包含我修改过的多个文件,但是由于某种原因被归类到这些文件夹中。

我需要将这些更改分成多个拉取请求,因此“ git commit -a”将不会执行。

我看到的最佳解决方案是“ git add -all”,复制“ git status”,然后再次“ git reset”,但这似乎很费劲。

有更好的解决方案吗?

tor*_*rek 5

Git仅跟踪文件(不跟踪文件夹/目录)。

但是,出于优化目的,如果可能的话,使用缩写格式git status 报告子目录/文件夹中未跟踪的文件。

要取消缩写,请使用git status -uall(即-u+ all,如“向我显示所有文件,而不是简短列表”中所述)。你也可以写-uno意味着显示没有文件,或只是-u其中的手段-uall呢。默认值为-unormal,这是普通的缩写版本。

您可以添加任何单个文件,例如:

git add folder1/foo.txt
Run Code Online (Sandbox Code Playgroud)

现在该文件已被跟踪,并且git status不再缩写:folder1/folder1/foo.txt跟踪以来,它必须一次列出所有仍未跟踪的文件。