You know the ones, all those config files sitting in your home directory
Have you ever gotten a new computer, wiped your old one, and only then realized that the one thing you forgot to copy over was all the config files sitting in your home directory? Or maybe you made some config changes and later want to go back to the old version?
Wouldn’t it be nice if all your config files could be version controlled in the cloud? Capable of being copied down to any new computer in seconds?
Turns out, doing so is pretty simple!
The MethodSection titled: The Method
The idea is to create a new subdirectory of your home directory, move all the config files into that folder, and then use a tool called GNU Stow to symlink each of the config files back into your home directory.
-
Create a new file in your home directory called
dotfiles
(or whatever you want to call it) -
Move all your config files into
dotfiles
, maintaining the same relative directory structure- Toggle the
switch below for an interactive exampleBefore
$HOMEdotfiles.gitignoreMusic.zshrc.awscredentials - Toggle the
-
Install GNU Stow with the package manager for your OS.
- On Mac you can install with Homebrew.
-
Invoke
stow
to create symlinks in your home directory- Now symlinks to all your config files should exist again in your home directory
- Editing the symlinked files will also edit the files inside of
dotfiles
-
Create a private remote repository
- Go to GitHub or GitLab or BitBucket or whatever remote repository provider you prefer and create a new private repo. Then copy the clone url for that repo.
-
Create a git repository inside of
dotfiles
and push to your remote repo
Now just edit your config files like normalSection titled: Now just edit your config files like normal
Boom, done! You can use and edit your config files like normal. Editing either file will update them both.
When you make changes to your config files, remember to commit and push those changes to your remote to back them up!
Add a README to your repoSection titled: Add a README to your repo
You can add a README.md
file inside dotfiles
to remind your future self how to use this repo.
It could look something like this: