【问题标题】:Git track untracked files without adding to commitGit跟踪未跟踪的文件而不添加提交
【发布时间】:2017-12-30 16:50:24
【问题描述】:

我运行了命令“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

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

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

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

有没有更好的解决方案?

【问题讨论】:

    标签: git version-control git-reset git-stage git-untracked


    【解决方案1】:

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

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

    要取消缩写,请使用git status -uall(即-u + all,如“显示所有文件,而不是缩短列表”)。你也可以写-uno,意思是显示no文件,或者只是-u,意思是-uall。默认为-unormal,即正常的缩略版。

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

    git add folder1/foo.txt
    

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

    【讨论】:

    • 谢谢,为我工作编辑:-uno 没有,但只是 -u 做了
    • @user2605633:哎呀,Braino,这是-uall!将修复答案。
    猜你喜欢
    • 1970-01-01
    • 2016-02-04
    • 2017-03-15
    • 2011-02-27
    • 2012-12-29
    • 1970-01-01
    • 2016-12-26
    • 2013-04-14
    • 2017-01-16
    相关资源
    最近更新 更多