Ignoring project files in git
Posted by David Zaslavsky onOver and over again, I have the need to synchronize files between my home computer, my office laptop, and possibly other computers as well. I use git because a lot of these files are things that I might conceivably want to keep a history of, and also because git makes it easy to set up a work environment on another computer.
Project metadata files get in the way of this, though. These are the files that fancier editors use to keep track of things like which files you had open, what syntax highlighting schemes you were using, and so on. The file typically gets changed every time you open the editor. Now, most of that information is pretty trivial, and I typically don’t want to synchronize it between computers or keep track of its history. On the other hand, when I’m setting up on a new computer, it’s pretty handy to have a project file available to start with, so I’m reluctant to exclude the files from the archive entirely.
Today, I found a solution. After you clone your git repository, in the new work environment, run
git update-index --assume-unchanged <projectfile>
This sets a flag which …