Live data from Hacker News

A Way to Manage Dotfiles

github.com

11–20 of 44 posts

Re: A Way to Manage Dotfiles

#11

I like the bare repository approach here. I've been using symbolic links to version control my dotfiles with git.

I gave it a quick glance but didn't understand, how is OP's link managing it instead of symbolic links?

Files are tracked by a bare git repository, e.g. `~/.dotfiles`.

The trick is to use the combination of --git-dir and --work-tree git options. An alias can be defined to simplify the process: `alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'`.

`dotfiles` can be used as you would use `git`, e.g.:

- `dotfiles add `

- `dotfiles commit [options]`

Re: A Way to Manage Dotfiles

#12

I like the bare repository approach here. I've been using symbolic links to version control my dotfiles with git.

I gave it a quick glance but didn't understand, how is OP's link managing it instead of symbolic links?

By telling git to use `--work-tree=$HOME`, they tell git to directly work on the files in their home directory; no symlinks needed.

Re: A Way to Manage Dotfiles

#13
post #10

I sync a directory of dotfiles across my workstations using syncthing. The .bashrc and .profile simply do: for FN in ~/.paths/sneak-sync/bashrc.d/*.sh ; do source $FN done Then updates (by adding or removing files to these directories) propagate to all my workstations. I have machine-specific ones, too, that also sync but aren't included due to differing hostnames.

Wow, that’s awesome.

Re: A Way to Manage Dotfiles

#14
post #9
post #6

I've been using this bare repository approach for a while. I forget where I first saw it, I'm pretty sure it was on HN but it was not this project. I do like it, but I have a few minor issues. The first is that I have a habit of running `git add .` when I'm working on source code, and as a result I have accidentally added my entire home directory to the bare repo more than once... Easy enough to undo but a bit inconv…

I, too, saw this approach on HN first – here: https://news.ycombinator.com/item?id=11071754 I combined the bare repo approach with a per-machine custom branch approach described in https://www.anishathalye.com/2014/08/03/managing-your-dotfil... The idea is that you have the shared configuration in one repo, and at the end of each config file, you include a local version. The local versions live in a separate reposito…

Yes that comment is where I first saw it, thanks for reminding me.

Thanks for those pointers and the link to your dotfiles too. I will check that out and maybe steal a couple of ideas!!

Re: A Way to Manage Dotfiles

#15
post #6

I've been using this bare repository approach for a while. I forget where I first saw it, I'm pretty sure it was on HN but it was not this project. I do like it, but I have a few minor issues. The first is that I have a habit of running `git add .` when I'm working on source code, and as a result I have accidentally added my entire home directory to the bare repo more than once... Easy enough to undo but a bit inconv…

I have a `.gitignore` file with `*` in it to ignore all files, so I explicitly type `dotfiles add --force`.

Re: A Way to Manage Dotfiles

#16
I've found that a simple dot_files directory that is sync'd via a public git repository [0] works well for me. When I'm on a new machine all I need to do is clone the repository and run `ln -s ~/dot_files/bash/bashrc ~/.bashrc`. The bashrc file then takes care of everything else.

It might not work for every program out there, but it does for the small number that I use.

[0] https://github.com/andypea/dot_files

Re: A Way to Manage Dotfiles

#17
post #10

I sync a directory of dotfiles across my workstations using syncthing. The .bashrc and .profile simply do: for FN in ~/.paths/sneak-sync/bashrc.d/*.sh ; do source $FN done Then updates (by adding or removing files to these directories) propagate to all my workstations. I have machine-specific ones, too, that also sync but aren't included due to differing hostnames.

[deleted]
Post reply on HN