0

I have two files .cat and .inf which are not mentioned in the .gitignore file. But still, they are greyed out in VS code which shows that they are not getting committed/uploaded to the git repo.

my-file.cat my-file.inf

I am using the visual studio default .gitignore file.

ref: https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

how to explicitly mention to include some files. or are there any global ignore settings in which these files are mentioned to be ignored by default?

Abubakar Riaz
  • 320
  • 8
  • 26
  • Sounds like the files are already tracked. If that is the case, `.gitignore` has no effect on them. There are other questions about how to deal with files you are tracking already but that you would like to ignore. – eftshift0 Mar 10 '23 at 08:42
  • how to ignore them from tracking? – Abubakar Riaz Mar 10 '23 at 09:26
  • It depends on what want as outcome, Do you want to _remove_ the files (while keeping them in your working tree) **from now on**? That's one possible way to handle it. Do you want to remove them from history altogether? That's a harder one, but still possible. Those approaches are handled in questions related to "how to delete and ignore a file that is tracked in git". It has been asked and answered many times already. – eftshift0 Mar 10 '23 at 09:32

2 Answers2

1

You can explicitly tell .gitignore file to include some files by prefixing a bang like

!my-file.cat
!my-file.inf

You should prefer to actually figure out what's making them be ignored though. (Maybe they're in an ignored folder?)

cSharp
  • 2,884
  • 1
  • 6
  • 23
  • right, so what are the other ways of gitignore settings I only know about .gitignore. – Abubakar Riaz Mar 10 '23 at 07:39
  • 1
    I meant, it's possible that your files that are ignored are in folders ignored by .gitignore (or maybe some other edge case). – cSharp Mar 10 '23 at 07:41
1

Use check-ignore to see which rule is ignoring the files:

git check-ignore -v my-file.cat

It will tell you which rule in which file is causing the file to be ignored. Then adjust that file accordingly.

1615903
  • 32,635
  • 12
  • 70
  • 99