Question

I just put my dotfiles in a repository in the manner suggested by Eli Barzilay here:

So I’ve finally found a solution that takes the best of both: put the repo in a subdirectory, and instead of symlinks, add a configuration option for “core.worktree” to be your home directory. Now when you’re in your home directory you’re not in a git repo (so the first problem is gone), and you don’t need to deal with fragile symlinks as in the second case. You still have the minor hassle of excluding paths that you don’t want versioned (eg, the “*” in “.git/info/exclude” trick), but that’s not new.

My .git/info/exclude looks like this:

*
.*.swp
*~
\#*#
.DS_Store

The * on the first line successfully ignores all files, so I add things explicitly with git add -f. However, this has the side effect that files I want ignored slip through.

Is there a way to tell git to really ignore certain files, even though I use add -f?

Was it helpful?

Solution

Right now there is no easy way to do this, because by putting * in .git/info/exclude you are essentially "blinding" git to which files you really want to be always ignored. That is one big downside of the detached working tree approach to dotfile management using git, and it's one of the reasons why I personally rejected this approach. Instead I wrote a plugin to mr which automates symlink farm management via GNU Stow.

However if you still want to stick with the detached working tree approach, you should definitely look at vcsh rather than reinventing wheels. I am currently working on making git's ignore mechanism more scriptable, and it's possible that this work could be consumed by tools like vcsh in the future to at least partially solve this problem. (I know vcsh's author and have just suggested this idea to him on IRC.)

Finally, I'd recommend hanging out with the vcs-home guys to understand all the options better.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top