A directory of brand guidelines: logosearch.link

The global .gitignore

Dom Habersack
Dom HabersackSeptember 23, 2020
A construction site warning sign telling people not to get closer.
You won’t have to keep telling your coworkers to gitignore their editor’s config files anymore.

In most teams, we’re free to choose whatever editors and tools we want to get our work done. Everybody uses the OS and editor of their choice, and we push everything to a shared repository. Some use VS Code on macOS, others use Sublime Text on Windows, yet others kick it oldschool with vim on Linux.

All these individual choices create file noise. Operating systems add files like .DS_Store to keep track of folder preferences. Editors keep your workspace settings in hidden files as well. We don’t normally want to add those system-specific files to our project repositories.

Let say Josh’s config file for VS Code says he likes to use two spaces for indentation. Becky uses the same editor, but she prefers four spaces for indentation. If both were to commit their configurations, they’d run into merge conflicts all the time.

To avoid this, we can add the troublesome files and directories to our project’s .gitignore file. Files and directories listed in there are not committed to the repository at all. Josh and Becky can keep using VS Code, but their settings never leave their computer.

This gets tedious when every developer’s individual settings end up in a project’s .gitignore. The entries that really matter get lost in a sea of one-off configuration files. Instead of this approach, every person can maintain their own global .gitignore. It works like a regular .gitignore in a project, but applies to this person’s machine globally. These settings apply system-wide, without having to list those files again per project.

If you happen to use VS Code, you can add its hidden files to your global .gitignore. That way, they will NEVER be added to any of the repositories you contribute to. That puts developers in charge of keeping their system-specific files out of repositories.

To set this up, create a global .gitignore file somewhere on your system. The name doesn’t matter; I call mine .gitignore_global so I can tell it apart from regular .gitignore files. You can then set that file to be your global “excludes file” with this command:

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

In this snippet, replace ~/.gitignore_global with the path to your system-wide .gitignore. Tada, you’re now happily ignoring things on your entire computer!

– Dom

Continue reading

An empty logbook
#64November 25, 2020

Get more value from your git log

We can customize the look of our git log to get more value out of fewer lines. In this issue, I walk you through how we can build a prettier log step by step.

A circus sign saying “original”.
#60October 28, 2020

The main branch

There was never a technical reason for us to call the source of truth “master” in Git. We can rename it to “main” or any other term in a few minutes.

Lines of candies.
#45July 15, 2020

JavaScript sorts arrays weird

By default, an array of numbers will not be sorted numerically. To avoid unexpected results, we can tell it how to sort an array.

Read all issues →