Home > other >  Can you put filename with 2 dots (.ext1.ext2) in the gitignore?
Can you put filename with 2 dots (.ext1.ext2) in the gitignore?

Time:12-10

E.g. i added this to ~/.gitignore

.js.2

but "git status" still reports

src/common/myService.js.2

as untracked files.

Is there a why to let git ignore this ?

CodePudding user response:

The number of dots isn't relevant. You simply forgot the asterisk in your entry. You're looking for:

*.js.2

More info here.

CodePudding user response:

Git provides a way to ignore some files and directories based on a file called .gitignore. This file considers each line as a regular expression to ignore (or not ignore).

If you set a line to any non empty sequence, git will check the non-tracked (!) files name against those entries and apply the rules if the file name matches the regular expression.

In your case, the file name does not match the regex since the file name is not a perfect match to .js.2. Instead, you may want to use *.js.2.

Here is the link to the official documentation. It is comprehensive and full of examples here.

  •  Tags:  
  • git
  • Related