Skip to content

Instantly share code, notes, and snippets.

@pcolazurdo
Last active March 26, 2021 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcolazurdo/05688278138b88579c067b5048c0d370 to your computer and use it in GitHub Desktop.
Save pcolazurdo/05688278138b88579c067b5048c0d370 to your computer and use it in GitHub Desktop.
Dotfiles setup recommendations

How to setup a git repo for your dotfiles

For general guidance follow this great write up: https://www.atlassian.com/git/tutorials/dotfiles

In summary:

On the main computer:

git init --bare $HOME/.cfg
alias dotfiles='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
dotfiles config --local status.showUntrackedFiles no
echo "alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> $HOME/.bashrc

To add some files

dotfiles status
dotfiles add .vimrc
dotfiles commit -m "Add vimrc"
dotfiles add .bashrc
dotfiles commit -m "Add bashrc"
dotfiles push

To add the files to a remote system

cd ~
echo ".cfg" >> .gitignore
git clone --bare <git-repo-url> $HOME/.cfg
alias dotfiles='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
dotfiles config --local status.showUntrackedFiles no
dotfiles checkout

Troubleshooting

if you receive an error like this

error: The following untracked working tree files would be overwritten by checkout:
    .bashrc
    .gitignore
Please move or remove them before you can switch branches.
Aborting

You could use:

mkdir -p .config-backup && \
config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | \
xargs -I{} mv {} .config-backup/{}
dotfiles checkout

Wrapping up

dotfiles config --local status.showUntrackedFiles no

My dotfiles at the moment:

.aws/config
.gitconfig
.multirc
.oh-my-zsh/custom/aliases.zsh
.oh-my-zsh/custom/example.zsh
.oh-my-zsh/custom/plugins/example/example.plugin.zsh
.oh-my-zsh/custom/themes/example.zsh-theme
.oh-my-zsh/custom/themes/powerlevel10k
.p10k.zsh
.zshrc

Some good examples of dotfiles:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment