The best way to manage dot files with Git is to use a "bare" repository. This is a special kind of repository that doesn't have a working directory, which is perfect because you don't want a .git
folder cluttering up your home directory.
Here’s the simple, step-by-step process.
cd ~
git init --bare $HOME/.dotfiles
dotfiles
as a command for managing your repository.alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
.bashrc
or .zshrc
) to make it permanent.git status
doesn't get cluttered.dotfiles config --local status.showUntrackedFiles no
dotfiles add .bashrc .zshrc .vimrc
dotfiles commit -m "Initial commit of dot files"
dotfiles remote add origin [email protected]:your_username/your_repo_name.git
dotfiles push -u origin main
🎉 Your dot files are now backed up on GitHub!
On a new computer, the process is just as easy.
.dotfiles
directory where Git will live.git clone --bare [email protected]:your_username/your_repo_name.git $HOME/.dotfiles
.zshrc
) after the setup.alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
dotfiles checkout
dotfiles config --local status.showUntrackedFiles no
.dotfiles
directory and execute the setup script you wrote. This script will automatically install Homebrew, Oh My Zsh, install all your apps from the Brewfile, and finalize your system configuration.cd $HOME
chmod +x install.sh
sh install.sh
That's it! Your perfect development environment is now just a few simple commands away, no matter what machine you're on.
Managing your dot files this way is a small change that can save you a ton of time and frustration in the long run. Happy coding!
Còn chút gì để nhớ
Bài cảm nhận tham gia cuộc thi "Trở lại học trò" do Nhà xuất bản Trẻ tổ chức nhân sự kiện ra mắt truyện dài "Lá nằm trong lá" 2011
My 2024 MacBook Pro Setup
I share how dotfiles made the migration simple, why I swapped iTerm2 for Ghostty, and how Catppuccin has become my new favorite theme. Plus, I reveal the candidates trying to replace my current browser.