Version control for my Linux configuration files using a bare Git repository.
-
Initial commit
-
Create a bare repository:
git init --bare $HOME/.dotfiles
-
Create an alias to manage the dotfiles:
alias dotfiles='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
-
Add the alias to your shell configuration:
echo "alias dotfiles='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >> $HOME/.bashrc
-
Exclude the
.dotfiles
directory from being tracked:echo ".dotfiles" >> $HOME/.gitignore
-
Tell git not to show untracked files
dotfiles config --local status.showUntrackedFiles no
-
Ensure sensitive information is not included
[!WARNING] Before committing, check for any sensitive information (e.g., API keys, passwords) and either remove or ignore those files.
-
Initial commit:
dotfiles add .bashrc .zshrc .vimrc # add others as needed dotfiles commit -m "Initial commit of dotfiles" dotfiles remote add origin <repo-url> dotfiles push -u origin main
-
-
Following commits
-
Example
dotfiles status dotfiles add .bashrc dotfiles commit -m "New alias" dotfiles push
-
-
Starship setup
-
curl -sS https://starship.rs/install.sh | sh echo 'eval "$(starship init bash)"' >> ~/.bashrc mkdir -p ~/.config && touch ~/.config/starship.toml
-
nano ~/.config/starship.toml
Paste in configuration, save, open new shell
-