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?

3
  • 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. Commented Mar 10, 2023 at 8:42
  • how to ignore them from tracking? Commented Mar 10, 2023 at 9: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. Commented Mar 10, 2023 at 9:32

2 Answers 2

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?)

Sign up to request clarification or add additional context in comments.

2 Comments

right, so what are the other ways of gitignore settings I only know about .gitignore.
I meant, it's possible that your files that are ignored are in folders ignored by .gitignore (or maybe some other edge case).
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.