DEV Community

Cover image for Dotfiles Backup using `chezmoi` (MacOS)
Mainendra
Mainendra

Posted on

Dotfiles Backup using `chezmoi` (MacOS)

Install chezmoi

  • Brew
brew install chezmoi
Enter fullscreen mode Exit fullscreen mode
  • Curl
sh -c "$(curl -fsLS https://chezmoi.io/get)"
Enter fullscreen mode Exit fullscreen mode

Backup

  • (First time) Create a new repo - $ chezmoi init
  • (First time) Create a github (or gitlab, etc) - https://docs.github.com/en/get-started/quickstart/create-a-repo
  • Add / Update dot files - $ chezmoi add ~/.zshrc, $chezmoi add ~/.config/neovim, etc
  • CD into local repo - $ chezmoi cd
  • Commit your changes - $ git commit -am "Initial commit"
  • (First time) Add remote origin - $ git remote add origin git@github.com:username/dotfiles.git
  • Push your changes to remote repo - $ git push -u origin main

Restore

  • (First time) Clone remote repo - $ chezmoi init https://github.com/username/dotfiles.git
  • Pull and apply the latest changes - $ chezmoi update -v

Reference: https://www.chezmoi.io

Top comments (0)