如何添加带有变量结尾(“扩展名”)的.gitignore文件,但开头是一样的

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

StackOverflow社区!我不能忽略具有特定名称的文件:list.vtk.1,list.vtk.2,list.vtk.3等。我尝试将list.vtk。*添加到.gitignore,但它不起作用。我输入git status时会看到文件。如何处理变量扩展?

在.gitignore:

# data files
out
*.vtk
list.vtk.*
log.*
*.log
*log
.idea
dump-*

输出是

On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   2phase_new/Makefile
    new file:   embed_2phase/embed_2phase.c
    new file:   two_phase_flow_cylinders/results/Ox=10_No_BC_effects/list.vtk.0
    new file:   two_phase_flow_cylinders/results/Ox=10_No_BC_effects/list.vtk.1
    new file:   two_phase_flow_cylinders/results/Ox=10_No_BC_effects/list.vtk.10
    new file:   two_phase_flow_cylinders/results/Ox=10_No_BC_effects/list.vtk.11
    new file:   two_phase_flow_cylinders/results/Ox=10_No_BC_effects/list.vtk.12
    new file:   two_phase_flow_cylinders/results/Ox=10_No_BC_effects/list.vtk.13
    new file:   two_phase_flow_cylinders/results/Ox=10_No_BC_effects/list.vtk.14
    new file:   two_phase_flow_cylinders/results/Ox=10_No_BC_effects/list.vtk.15
    new file:   two_phase_flow_cylinders/results/Ox=10_No_BC_effects/list.vtk.16

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
    deleted:    two_phase_flow_cylinders/results/Oy mmm/list.vtk.0
    deleted:    two_phase_flow_cylinders/results/Oy mmm/list.vtk.1
    deleted:    two_phase_flow_cylinders/results/Oy mmm/list.vtk.10


Untracked files:
  (use "git add <file>..." to include in what will be committed)

    ../scratch.cpp
    2phase_new/parout
    2phase_new/results/manycyls_front/flow.avi
    2phase_new/results/manycyls_front/flow.mp4
    paraview/reserve
    reversed_3f-implicit/diff
    reversed_3f-implicit/f2
    reversed_3f-implicit/f3
git
1个回答
0
投票

你的.gitignore模式list.vtk.*工作得很好,但是

  • 在添加该模式之前,您已在其中一些文件上调用了git add。因此他们被列为new file。像git本身所暗示的那样做一个git reset HEAD <file>
  • 在添加模式之前已经提交了三个其他文件,但现在已丢失。它们被列为deleted。像git本身所暗示的那样做一个git rm <file>

.gitignore机制仅适用于将在Untracked files:部分列出的文件。一旦跟踪它们,.gitignore就不再适用了。

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