git: ignoring files

2021-08-10

 | 

~1 min read

 | 

185 words

The most common way to ignore files from git is with a .gitignore file in a repository. However, that’s not the only way to do it!

Other mechanisms include:

  1. Creating a global .gitignore
  2. Ignore files in a repository without a .gitignore

Global .gitignore

To create a global .gitignore file that will be used by every repository managed by the git config file (remember, you can have multiple git configs), you can create one with the command:

% git config --global core.excludesfile ~/.gitignore_global

Ignore Files without .gitignore

If you’re creating files locally that you want to ignore (e.g., a test report), but that you may not want to include in a .gitignore, you can ensure that they’re not tracked locally by modifying the .git/info/exclude file.

Rules are added just like a .gitignore, however, it’s not committed to the repository, so it’s local only to your machine.

Conclusion

If you’re like me, you have a lot of repositories, and so having a list of .gitignore templates is really useful. However, with the `.global

Sources


Related Posts
  • 2021 Daily Journal


  • Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!