In a project where for instance a parser is involved, some source code is the product of a program. For instance yacc
generates - based on a .yy
file - a source code file that implements the parser.
Since small modifications in the .yy
file can lead to large changes in the corresponding source code file after compilation and since the resulting source code is (almost) never altered after it is generated. Such source code files are perfect candidates for the .gitignore
list.
Now one can of course write such files manually to the list:
lexer1.cpp
parser1.cpp
lexer2.cpp
parser2.cpp
But it is likely when one builds a new parser, he/she will forget to add the file to the list.
Is there a way to specify a pattern that acts as follows:
Given a file foo.ext1
exists, ignore foo.ext2
.
Where one thus provides ext1
and ext2
. In the case of the lexer/parser, this would mean applying this pattern for .xx
/.cpp
and .yy
/.cpp
.
This is probably not possible by .gitignore
directly, but perhaps there are some hooks already implemented for this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…