-1

When I type git status, I get the output below.

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/

Then I make a commit with git commit -m 'Test commit.', Somehow, the untracked files show up in the 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
...

Why do the untracked files show up in the commit even though there were only 3 files under Changes to be committed?

Marc K
  • 261
  • 3
  • 8
  • 23
Victor Cui
  • 1,393
  • 2
  • 15
  • 35

1 Answers1

1

Untracked files do not get commited. In your case husky staged the untracked files in some of the pre-commit hooks he ran, so at the time of commit those files were not untracked.

magikarp
  • 129
  • 7