.gitignore is a file used in Git repositories to tell Git what files it should not track in the repository, for example if you had a file that contained an API key, you would absolutely not want that key to be stored in the repository, so you can add the filename to the
.gitignore to prevent it from being stored.
If your project isn’t contained in a Git repository you don’t need to have a
.gitignore but if it is (and in general it’s a good idea to use Git for projects) you can create it just like anyother file, so long as it has
.gitignore as the file name.