5 ms·
Why not just have a git repo working copy in your $HOME directory? That way you can avoid any symlinking mess. The actual dotfiles are the ones from the working
by shtylman 15y ago
Why not just have a git repo working copy in your $HOME directory? That way you can avoid any symlinking mess. The actual dotfiles are the ones from the working copy.
I used to do symlinking but found the working copy in $HOME approach much better.
- nixme 15y agoI do the same (https://github.com/nixme/dotfiles https://github.com/nixme/dotfiles). To minimize noise, I put * in my .gitignore so only files that are 'add -f' are tracked.
- jpiasetz 15y agoIt's a bit of a trade off between symlinking mess and .git mess. I just prefer a cleaner home folder. I did try it all in home for a bit.
- shtylman 15y agoWhat .git mess? I think the working copy in $HOME is cleaner as you don't have symlinks everywhere. The only new addition to your home folder is a '.git' directory. This is no different than the myriad of other hidden directories already there.
- technomancy 15y agoI did this for four years, but I stopped because it's too easy to miss new files with the wide gitignore it requires.
- fr0sty 15y agoThat could work, but where would the .git/ directory be? If you have in $HOME/.git you are inviting disaster with an errant 'git clean...' command. If not you need to deal with managing the options/environment to make the git commands work (though that could be scripted). I'm curious about this too since something dead simple (and reasonably idiot-proof) would be useful to me as well.
- nixme 15y agoWith * in .gitignore, you'd have to use '-x' with 'git clean' to delete everything. That's idiot-proof enough for me.
- fr0sty 15y agoDo you intend to never use 'git clean -x...' anywhere in your home directory? when you run 'git <command>' git will go upward through the directory tree until it finds a .git directory. If you intend to run 'git clean -fx' in ~/foo/project/src but are instead in ~/foo/tmp/src/ (which is not a git repository) it will run that clean against all of ~/ instead. Having ~/dotfiles/.git and aliasing a command that sets GIT_DIR=~/dotfiles/.git and GIT_WORKDIR appropriately would be safer.
- shtylman 15y agogreat suggestion. I added an alias of 'dotfiles' to my environment which prefixes the git command with the GIT_DIR and GIT_WORKDIR described above. Now when I want to work with my dotfiles I just use that command instead of 'git' directly.
- nixme 15y agoI understand the .git search path, but I almost never use `git clean` in my projects (usually just `git reset --hard` or `make clean`), so I've never been too worried. But your solution is definitely safer -- although I think you meant GIT_WORK_TREE, not GIT_WORKDIR, right? I'm going to switch. Thanks! EDIT: Working nicely :) https://github.com/nixme/dotfiles/commit/64486fe25e6750567a01cea49f527686c56ea365 https://github.com/nixme/dotfiles/commit/64486fe25e6750567a0...
- fr0sty 15y ago> I... usually just `git reset --hard` This is still risky if your ~/.git had uncommitted changes. I'll admit to being a little paranoid but I spent enough time on the #git irc channel to learn that any advice that is potentially dangerous will _always_ be used in the dangerous fashion, often without knowledge of the risks. > although I think you meant GIT_WORK_TREE, not GIT_WORKDIR, right? Yeah, brain cramp on that one, sorry.