Just Use `git` to Manage Your Dotfiles
Posted4 months agoActive4 months ago
ericgreer.infoTechstory
calmmixed
Debate
40/100
Dotfiles ManagementGitConfiguration Management
Key topics
Dotfiles Management
Git
Configuration Management
The article suggests using `git` to manage dotfiles, sparking a discussion on the pros and cons of this approach and alternative methods for managing configuration files.
Snapshot generated from the HN discussion
Discussion Activity
Light discussionFirst comment
1h
Peak period
5
2-4h
Avg / period
3.5
Comment distribution14 data points
Loading chart...
Based on 14 loaded comments
Key moments
- 01Story posted
Aug 31, 2025 at 5:21 AM EDT
4 months ago
Step 01 - 02First comment
Aug 31, 2025 at 6:30 AM EDT
1h after posting
Step 02 - 03Peak activity
5 comments in 2-4h
Hottest window of the conversation
Step 03 - 04Latest activity
Sep 1, 2025 at 5:44 AM EDT
4 months ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
ID: 45081764Type: storyLast synced: 11/20/2025, 5:57:30 PM
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.
The problem with this approach is that you can accidentally commit to the $HOME repository.
An approach that avoids that is to use --git-dir= attribute.
E.g. alias dotfiles="git --git-dir=$HOME/.dotfiles"
I’ve tried everything from raw git to gnu stow to manual symlinking and everything in between. They all work when the full context of the workflow is fresh in my brain. But after a few weeks I always mess up, even though I’ve documented the process in my dotfiles repo.
I eventually settled on chezmoi, and it just works. I set it up a year ago and haven’t needed anything beyond chezmoi -v diff and chezmoi -v apply.
I know my way around emacs. vimdiff is a foreign country.
Often my changes are speculative or experimental. So I checkout, edit, apply and only then discover I’ve messed up. Or I can edit in place. Voila vimdiff!
What’s the better way?
I switched to it after maintaining a custom written POSIX sh script that kept getting further and further out of hand.
I don't see myself going back to a self-maintained one unless I'm writing it in Rust.
You don't have to use vimdiff. You can use any merge tool you want. See https://www.chezmoi.io/user-guide/tools/merge/.
> Often my changes are speculative or experimental. So I checkout, edit, apply and only then discover I’ve messed up. Or I can edit in place. Voila vimdiff!
> What’s the better way?
There are lots of options. See https://www.chezmoi.io/user-guide/frequently-asked-questions....
Personally, I tend to use `chezmoi edit` and then use git in my source directory to `git add -p . && git commit` the changes I want to keep and `git checkout` to discard the changes I don't want.
The canonical workflow is this: you run chezmoi cd and make changes there first. Only then do you run chezmoi apply to propagate the changes to the original location.
The source of truth is always what lies in the chezmoi directory, not the other way around.
So if you’re experimenting with the dotfiles in their original location, running chezmoi apply will override them with the snapshot in the chezmoi directory. The vimdiff doesn’t do much here.
If you want to retain your changes there, you’ll have to manually copy them over to the chezmoi directory. This is a bit awkward, but having a consistent source of truth makes the behavior easier to reason about. I rarely look at the diff.
https://news.ycombinator.com/item?id=11071754
I’ve found this helpful for evaluating new packages without cluttering my home directory. It’s especially helpful when using many packages that don’t respect the XDG Base Directory specification; they tend to dump dotfiles directly in my home directory, so keeping it clean is important.