How to tell git to ignore individual lines, i.e. gitignore for specific lines of code [duplicate]

This question already has answers here: Can git ignore a specific line? (9 answers) Closed 7 years ago. .gitignore can ignore whole files, but is there a way to ignore specific lines of code while coding? I frequently and repeatedly add the same debug lines in a project, only to have to remember to remove … Read more

What is .gitignore?

I just created a Github repository and was wondering what the .gitignore file was for. I started by not creating one, but added one due to the fact that most repositories have one. Do I need to have one? Can/do I just ignore it, or does it have a use? 6 Answers 6

git ignore all files of a certain type, except those in a specific subfolder

I have a directory structure like this: root folder1 abc.json def.json somedir more.json folder2 qwe.json rty.json spec mock1.json mock2.json somedir more_mocks.json Now using a .gitignore I want to ignore all *.json files except for the ones in the spec. I don’t want to use a .gitignore in folder1 and folder2 because there are a ton … Read more