4 ms·
I just make my home directory be a git repo directly. That's even simpler -- no symlinks. You have to get used to having a repo with many unchecked-in files, bu
by cespare 5y ago
I just make my home directory be a git repo directly. That's even simpler -- no symlinks. You have to get used to having a repo with many unchecked-in files, but it works well enough. I have a git alias or two to help. This has been a good solution for me for more than a decade across ~a dozen OS installations.
- Arnavion 5y agoI've seen a few people doing this, but I also frequently run `git clean -xffd` in my actual source code directories to clean them, so I'd be deathly scared of accidentally running it in the wrong directory and wiping out half my homedir.
- encryptluks2 5y agoSnapshots to the rescue
- Morphion 5y agoalias config="/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME -c status.showUntrackedFiles=no -c submodule.recurse=true -c alias.update="'"!bash '"$HOME"'/.config/dotfiles/update_dotfiles.sh"'
- Arnavion 5y agoYou misunderstand. I'm talking about intending to run `git clean -xffd` under `~/src/some-project` (a git repo for some code) but accidentally running it under some other directory, such that it ends up running against `~` Making aliases for working with `~`'s repo doesn't prevent that.
- larschdk 5y agoYes it does. I do the same, with an alias and have .git somewhere else not directly in $HOME, but pointing to it with --git-dir. If you run git in ~, it will not recognize it as a git repository or worktree. You can only modify the repo with the alias or by specifying --git-dir explicitly. These setup also prevents zsh/bash git prompt extensions from detecting git the the home folder repo, which can be confusing, I think.
- Arnavion 5y agoOh, I missed the `--git-dir` part. My bad.
- deleted 5y ago[deleted]
- pixelmonkey 5y agoI do the same. It may benefit you to add "*" to .gitignore, as I describe here: https://news.ycombinator.com/item?id=25564558 https://news.ycombinator.com/item?id=25564558
- gbrown_ 5y agoThis is exactly what I do too. No messing with magic aliases to tweak --git-dir and --work-tree, just vanilla git.
- scottwernervt 5y agohttps://www.electricmonk.nl/log/2015/06/22/keep-your-home-dir-in-git-with-a-detached-working-directory/ https://www.electricmonk.nl/log/2015/06/22/keep-your-home-di... has been working nicely for me on multiple computers.
- 0xbadcafebee 5y ago^ This is the best solution I've found (detached head). Add a single cron line to automatically commit and push changes and you get automatic backup of dotfile changes. The only thing missing now is for pass to handle files as secrets.
- saagarjha 5y agoNested git repositories can cause problems which you may want to watch out for.