3 ms·
With * in .gitignore, you'd have to use '-x' with 'git clean' to delete everything. That's idiot-proof enough for me.
by nixme 15y ago
With * 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.