1. Edit your config

Add an excludes file to your ignore file.

$ git config --global core.excludesfile '~/.gitignore'

Note the quotes to prevent tilde expansion in the shell. This makes it more reusuable, like if you have the same config on differen machines with different usernames or operating systems, you wonโ€™t have /home/mcurrin or whatever hardcoded in there.

Or add the following to your ~/.gitconfig config file directly, then save it.

[core]
	excludesfile = ~/.gitignore

2. Create the ignore file

  1. Create and edit a file here e.g.
     $ vim ~/.gitignore
    
  2. Add any rules to it. For example:
     # Linux folder attributes and PyCharm metadata.
     .idea
        
     # Mac folder attributes
     .DS_Store
    
     # Directories for todo items, local notes and testing code.
     _TODO
     _NOTES
    
  3. Save and exit.

3. Test the ignoring

The change will appear in your IDE.

Check with CLI steps:

  1. Navigate to a repo.
  2. Create a file or folder which is in your ignore list.
  3. Then run:
     $ git status
    
  4. You will see the file or folder will be ignored.