Vince Aggrippino

Web Development

I like to talk about HTML, CSS, JavaScript, TypeScript and Accessibility.

Newest blog post:

Git Exclude Folder: Explained

A cartoon image depicting a bipedal octo-cat with pink skin, green eyes, and blue suckers on his tentacles. The octo-cat has white whiskers and bushy white mustache and eyebrows. He is wearing a suit vest with dress shirt, pants, and a tie teaching a complex topic using many charts, graphs and diagrams written on a chalkboard. There is a single student wearing a suit that is probably a school uniform.

To exclude a directory from git diff, use the following command:

git diff -- . ':!directory_name'

You can find this exceptionally terse answer at at least a dozen search results, but not a single one offers an explanation. Well, that's not enough info for me...

The "pathspec" is documented under git help gitglossary and is used for many git commands even if their syntax statement shows <path> instead of <pathspec> :

https://git-scm.com/docs/gitglossary#def_pathspec

Here are the important points:

I wanted to see what had changed in an Eleventy site, excluding the generated output files. So, here's the command I used:

git status -- ':!:_output'

Note that I needed to terminate the magic signature with another colon because the path I wanted to exclude started with an underscore (_). Without that second colon, I got an error message:

fatal: Unimplemented pathspec magic '_' in ':!_output'`