Over several years now I’ve used Git in developing patches for WordPress core, for which we committers still use SVN to actually commit patches, for better or worse. While working on patches in a fork, however, Git is definitely for better. I’ve found a lot of value in using GitHub for reviewing and collaborating on patches via pull requests. I actually have the SVN checkout and the Git clone both sitting in the same directory—
.git sitting in a tree (👩❤️💋👨). There is a
.gitignore committed into the WordPress repo even though it is is SVN, but it only ignores the most common files that may end up in the directory. Over the years I’ve accumulated a bunch of files in the directory tree (ones which I really should really do some spring cleaning on, but… 🍂). If I added those files to the
.gitignore then it would also then appear as dirty unless I also then do
git update-index --assume-unchanged .gitignore, but that seems liable to cause problems down the road. Today, however, I ran across an alternative in a feature of Git I hadn’t seen before.
There’s plenty of directories as well: […]
info: Relatively uninteresting except for the
excludefile that lives inside of it. We’ve seen this before in the ignoring files article, but as a reminder, you can use this file to ignore files for this project, but beware! It’s not versioned like a
.gitignorefile would be.
This is exactly what I’ve needed. I can add all of my untracked files in the directory tree to this file and not get noise anymore when I do
git status. As a bonus, here’s a one-liner command to add all of the untracked files to be ignored:
git status --untracked-files=normal --porcelain | ack '^\?\?' | cut -c4- >> .git/info/exclude
Ah… “nothing to commit, working tree clean.”