gitignore所有目录中的特定文件格式[重复]

问题描述 投票:0回答:1

我想在所有目录中排除文件格式,例如*.simg。我试图在*.simg中添加.gitignore,但文件仍在git status中可见。

我具有如下文件夹结构,.gitignore文件位于根目录中:

-service-foo/foo.simg
-service-bar/bar.simg
-composite-service/service-foobar/foobar.simg
-.gitignore

如何排除所有目录中的格式?

编辑1:

.gitignore文件如下:

HELP.md
target/
.mvn/
.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**

### SINGULARITY simg###
*.simg

[当我执行git status时我得到:

javaadmin@THNJAVA11:~/server/airadhi-server$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   .gitignore
        modified:   composite-service/foobar.simg
        modified:   composite-service/service-foobar/foobar.recipe
        deleted:    service-foo/foo.simg
        modified:   service-bar/bar.simg

no changes added to commit (use "git add" and/or "git commit -a")
git gitignore
1个回答
2
投票

您在.gitignore中所做的操作是正确的。您需要通过执行git rm -r --cached <filename/pathspec>从登台区域中删除文件,然后提交更改。下次文件有任何更改时,它们都不会造成麻烦:)

您可能还要参考this

最佳

© www.soinside.com 2019 - 2024. All rights reserved.