【问题标题】:Why do untracked files get committed?为什么未跟踪的文件会被提交?
【发布时间】:2020-11-21 16:53:09
【问题描述】:

当我输入git status 时,我得到下面的输出。

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   services/replication/jobs/go.mod
        new file:   services/replication/jobs/go.sum
        modified:   services/replication/jobs/job.go
Changes not staged for commit:
      ....

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .circleci/pagerduty.sh
        common/nodejs/universal-search/src/utils/aspect_ratio.spec.ts
        common/nodejs/universal-search/src/utils/aspect_ratio.ts
        common/nodejs/universal-search/src/utils/index.ts
        infra/universal_search_apple/pulumi/resources/route53/

然后我用git commit -m 'Test commit.' 提交,不知何故,未跟踪的文件出现在提交中。

husky > pre-commit (node v14.5.0)
????  Finding changed files since git revision b495d278.
????  Found 0 changed files.
✅  Everything is awesome!
No staged files match any of provided globs.
[gps-289 b613c603] Test commit.
 15 files changed, 248 insertions(+), 454 deletions(-)
 create mode 100644 common/nodejs/universal-search/src/utils/aspect_ratio.spec.ts
 create mode 100644 common/nodejs/universal-search/src/utils/aspect_ratio.ts
 create mode 100644 common/nodejs/universal-search/src/utils/index.ts
 delete mode 100644 external/ambient.d.ts
 delete mode 100644 infra/metadata/Pulumi.dev.yaml
 delete mode 100644 infra/metadata/Pulumi.prod.yaml
...

即使Changes to be committed?下只有3个文件,为什么提交中仍显示未跟踪的文件

【问题讨论】:

  • 你在比较苹果和橘子。
  • 您能详细说明一下吗?
  • 首先你和 git 对话,然后你和 husky 对话。您正在与两个不同的人谈论两种不同的事情。找出您使用 git “提交”中的文件的方法是询问 git

标签: git github husky


【解决方案1】:

未跟踪的文件不会被提交。在您的情况下,husky 在他运行的一些预提交挂钩中暂存了未跟踪的文件,因此在提交时这些文件并未未跟踪。

【讨论】:

    猜你喜欢
    • 2017-12-30
    • 1970-01-01
    • 2017-08-04
    • 2018-02-28
    • 2012-03-28
    • 2014-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多