How to git ignore a file

Hi , i’m a newbie at using git and github and I want to commit and repos a project but there is a file that i would like to ignore from this repos.

So i’m using the git bash and I understood that I can create a git ignore file in the CL with :
$touch gitignore

but then ? Should i open the note created and put just the name of my file because when I did that, there was no effect and my file i wanted to ignore was still committed.

Thanks !

The ignore file must be named .gitignore, with a dot at the start. And yes, its simplest form is just one name or pattern to ignore per line. The gitignore documentation also has examples.

The ignore file does not apply to files that are already part of the repository, you’ll have to clean that up separately.

1 Like