.gitignore不忽略未跟踪的* .pb.go文件

时间:2020-01-31 19:27:24

标签: git

我不知道为什么,更新了顶层.gitignore以忽略扩展名为pb.go的生成文件后,仍然看到带有该扩展名的未跟踪文件。

# > cat .gitignore
*.pb.go

# > git status
Changes not staged for commit:
        modified:   .gitignore

Untracked files:
        some/path/filename.pb.go

基于对stackoverflow的类似问题的回答,我认为有必要强调以下事实:该pb.go文件是未跟踪的,它不在git缓存中,如

所示。
# > git rm -f --cached some/path/filename.pb.go
fatal: pathspec 'some/path/filename.pb.go' did not match any files

尽管生成的文件完全有可能在历史记录中的某个时刻存储在git中。

1 个答案:

答案 0 :(得分:0)

使用{p>

.gitignore

这导致* !*.go 未被排除。