Ignoring Files in Git
- Create a file named
.gitignore
horizontal to (i.e. in the same directory
as) your git repository. You will need to enable hidden files or use $ ls
-a
to see it.
- Open
.gitignore
in your text editor.
- List the files or folders you want git to ignore, one per line.
- Add and commit the
.gitignore
file to git.
- (Optional) If you have already committed the files you want to ignore, you
will need to tell git to forget about them:
forget about.
$ git rm --cached <file-or-folder>
Example .gitignore file
.DS_Store
tmp/
secrets.md