Skip to content

💠 My dotfiles repository with all the configuration files for the programs I use.

Notifications You must be signed in to change notification settings

zahradnik-ondrej/dotfiles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💠 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.)


Create a new dotfiles repository:

  1. mkdir $HOME/.dotfiles
  2. git init --bare $HOME/.dotfiles
  3. echo "alias dots='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >> $HOME/.bashrc
  4. bash
  5. dots config --local status.showUntrackedFiles no
  6. 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
  7. dots remote add origin https://github.com/<username>/<repository_name>.git

Add / update a dotfile:

  1. dots add <file/directory_name>
  2. dots commit -m "Add/Update <file/directory_name(s)>"
  3. dots push 3

Update all dotfiles:

  1. dots add -u
  2. dots commit -m "Update all files"
  3. dots push 3

Remove a dotfile:

  1. dots rm <file_name> or dotfiles rm -r <directory_name>
  2. dots commit -m "Remove <file/directory_name(s)>"
  3. dots push 3

Update the local repository:

  • dots pull

Clone (download) a dotfiles repository:

  1. echo "alias dots='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >> $HOME/.bashrc
  2. 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)
  3. bash
  4. dots checkout -f
  5. dots config --local status.showUntrackedFiles no
  6. bash

Footnotes

  1. 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. ↩

  2. 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). ↩

  3. You might sometimes come across this or similar error message which prevents you from pushing (uploading) your dotfiles to the repository when you run the dots push command: To https://github.com/<username>/<repository_name>.git ! [rejected] main -> main (fetch first) error: failed to push some refs to 'https://github.com/<username>/<repository_name>.git' hint: Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes (e.g., 'git pull ...') before pushing again. See the 'Note about fast-forwards' in 'git push --help' for details. To solve this issue, simply run the dots pull command which will then proceed to open your default text editor. You can then just exit the text editor (for nano: Ctrl + x / for emacs: Ctrl + x followed by Ctrl + c) and run the dots push command once again and everyting should be taken care of. ↩ ↩2 ↩3

About

💠 My dotfiles repository with all the configuration files for the programs I use.

Topics

Resources

Stars

Watchers

Forks