💠dotfiles 1
A better way to manage your dotfiles (or any other non directory-specific files 2).
You will never have to put all your dotfiles into one folder or use symlinks ever again.
(The instructions below have been made to work on Linux operating systems, specifically on Ubuntu 22.04 along with the prerequisite of having Git installed on your system.)
mkdir $HOME/.dotfiles
git init --bare $HOME/.dotfiles
echo "alias dots='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >> $HOME/.bashrc
bash
dots config --local status.showUntrackedFiles no
- create a new repository on GitHub (or any other Git server hosting service) but do NOT include a
README.md
or any other files such as a license dots remote add origin https://github.com/<username>/<repository_name>.git
dots add <file/directory_name>
dots commit -m "Add/Update <file/directory_name(s)>"
dots push
dots add -u
dots commit -m "Update all files"
dots push
dots rm <file_name>
ordotfiles rm -r <directory_name>
dots commit -m "Remove <file/directory_name(s)>"
dots push
dots pull
echo "alias dots='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >> $HOME/.bashrc
echo '.dotfiles' >> .gitignore
3a.git clone --bare https://github.com/<username>/<repository_name>.git $HOME/.dotfiles
(general dotfiles repository)
3b.git clone --bare https://github.com/zahradnik-ondrej/dotfiles.git $HOME/.dotfiles
(this dotfiles repository)bash
dots checkout -f
dots config --local status.showUntrackedFiles no
bash
Footnotes
-
Inspired by a YouTube video from DistroTube - Git Bare Repository - A Better Way To Manage Dotfiles and a blog post by Nicola Paolucci - Dotfiles: Best Way to Store in a Bare Git Repository. ↩
-
While this approach mainly serves as a better way to manage dotfiles, there is nothing special about it so that it couldn't be used for other types of files. That means you could use this approach for backing up any kind of data such as documents (Word, PDF, etc.), media files (pictures, videos, music) or software, especially if you are hosting your own Git server or paying for one (that's mainly due to storage, security and privacy concerns when it comes to backing up your data this way). ↩