Skip to content

en9inerd/sdfm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sdfm - Simple DotFiles Manager

A lightweight Bash tool for managing your dotfiles in a Git repository with easy backup and environment switching.


Features

  • Initialize or clone a dotfiles repository
  • Track files and directories under $HOME
  • Create and switch between environments (branches)
  • Backup existing files before applying new ones
  • Tag and version your configurations
  • Synchronize with remote
  • Minimal dependencies (Bash, Git, rsync)

Installation

You can install sdfm automatically with the provided install.sh script:

curl -fsSL https://raw.githubusercontent.com/en9inerd/sdfm/master/install.sh | bash

Usage

sdfm <command> [options]

Run sdfm help for a full command list:

Repository Setup:
  init --remote <url> [--branch <branch>]        Initialize dotfiles repo
  clone <url> [--branch <branch>]                Clone remote repo
  create-empty-branch <branch>                   Create new empty orphan branch

Environment Management:
  switch <branch>                                Switch to environment (Git branch)
  copy <new-branch>                              Create and switch to a new branch
  sync [--force] [--dry-run]                     Sync with remote (requires --force)
  pull [--merge]                                 Pull from remote (fast-forward default)
  push                                           Push current branch
  tag <name>                                     Create and push a tag
  list-tags                                      List tags
  checkout-tag <tag>                             Checkout a tag

File Tracking:
  add <file>...                                  Copy file(s) from $HOME to repo
  rm <file>...                                   Remove file(s) from repo
  list                                           List tracked files
  update [--dry-run]                             Update tracked files from $HOME
  status                                         Show status
  log                                            Show log
  diff                                           Show differences between $HOME and repo
  apply [--dry-run]                              Backup and apply dotfiles to $HOME

Backup Maintenance:
  list-backups                                   List available backups
  restore <timestamp>                            Restore files from a backup
  cleanup-backup [--keep-days <n>] [--dry-run]   Delete old backups (default: 30 days)

Other:
  git <args>                                     Run arbitrary git command in repo
  help                                           Show this help

Example Workflow

  1. Initialize a new repository
sdfm init --remote git@github.com:yourname/dotfiles.git --branch main
  1. Add and commit dotfiles
sdfm add ~/.bashrc ~/.vimrc ~/.config/nvim
  1. Push changes
sdfm push
  1. Apply configuration

This backs up current files before overwriting them:

sdfm apply
  1. Switch environments

Create a new branch:

sdfm copy work-env

Switch to it:

sdfm switch work-env
  1. Sync with remote
sdfm sync --force
  1. Tag configuration
sdfm tag initial-setup

List tags:

sdfm list-tags

Checkout a tagged version:

sdfm checkout-tag initial-setup

Backups

Every apply creates a backup in:

$HOME/.local/share/sdfm/backups/<timestamp>

List available backups:

sdfm list-backups

Restore from a backup:

sdfm restore 20260201143022

Clean up old backups (older than 30 days by default):

sdfm cleanup-backup
sdfm cleanup-backup --keep-days 7
sdfm cleanup-backup --dry-run  # Preview what would be deleted

Dry-Run Mode

Preview changes before applying them:

sdfm apply --dry-run      # See what files would be overwritten
sdfm update --dry-run     # See what files would be updated in repo
sdfm sync --dry-run       # See what local changes would be discarded

Safety Features

  • Sensitive file warnings: Adding files matching patterns like .ssh/id_*, .env, *credentials* will prompt for confirmation
  • Sync protection: sync requires --force flag if there are local changes to discard
  • Automatic backups: Every apply backs up existing files first

Requirements

  • Bash
  • Git
  • rsync

License

MIT

About

Simple DotFiles Manager

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages