My personal dot files.
See Create a New Repo to create your own dotfiles repository for the first time.
See Copy Dotfiles to Another Machine to migrate your dotfiles to a new machine.
See Set Up Permanent Aliases to set up custom short-cut commands.
See MISC for additional instructions.
Create your own dotfiles repo and sync with your machine.
Create an empty repo on GitHub.
Create a new bare Git repo to store the history for your dotfiles.
git init --bare $HOME/dotfiles
Tell Git that it should use your home directory as the snapshot for this bare Git repo.
Note: See Set Up Permanent Aliases to set this command permanently.
alias dotgit='git --git-dir=$HOME/dotfiles/ --work-tree=$HOME'
First, create a function.
function dotgitsetup { git --git-dir=$HOME/dotfiles/ --work-tree=$HOME @args }
Then assign that function to an alias.
Note: See Set Up Permanent Aliases to set this command permanently.
Set-Alias -Name dotgit -Value dotgitsetup
Tell Git that this repo should not display all untracked files.
dotgit config status.showUntrackedFiles no
Add files and commit.
Note: Whenever you want to add a new dotfile to your Git repo, use your aliased Git command.
dotgit status
Add individual files (recommended).
dotgit add dotfile1 dotfile2
Note: It is not recommended to run dotgit add .
as this will add all files under your home directory.
dotgit commit -m "add git dotfiles"
dotgit remote add origin https://github.com/waldronmatt/dotfiles.git
dotgit push --set-upstream origin main
This section provides instructions for migrating your dotfiles repo on Github to your local machine.
Clone your repo onto the new machine as a non-bare repository.
git clone --separate-git-dir=$HOME/dotfiles https://github.com/waldronmatt/dotfiles.git dotfiles-tmp
Copy the snapshot from your temporary directory to the correct locations on your new machine.
rsync --recursive --verbose --exclude '.git' dotfiles-tmp/ $HOME/
Copy-Item -Path "$HOME\dotfiles-tmp\*" -Destination "$HOME/" -Recurse -Exclude ".git"
Remove the temporary directory.
rm -rf dotfiles-tmp
Remove-Item -Force -Recurse -Path "$HOME\dotfiles-tmp\"
Repeat steps 2 - 4 above in the section Create a New Repo.
Instructions for setting up permanaent aliases to more easily maintain dotfiles.
Create a new file to store your alias configurations.
touch ~/.bash_aliases
Inside .bash_aliases
, save your aliases:
alias dotgit='git --git-dir=$HOME/dotfiles/ --work-tree=$HOME'
Have your linux system's ~/.bashrc
file load your custom ~/.bash_aliases
file.
if [ -e $HOME/.bash_aliases ]; then
source $HOME/.bash_aliases
fi
Now you can run your dotgit
from anywhere. Aliases will remain even with terminal/machine restarts.
Enter the following command to allow scripts to run and set the execution scope to the current user.
Note: Read more about the security policy here.
set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Create a new file called profile.ps1
and save the file in the following directory.
$Home\My Documents\WindowsPowerShell\profile.ps1
Inside profile.ps1
, save your aliases.
First, create a function
function dotgitsetup { git --git-dir=$HOME/dotfiles/ --work-tree=$HOME @args }
Then assign that function to an alias.
Set-Alias -Name dotgit -Value dotgitsetup
Save profile.ps1
, and restart your PowerShell terminal.
Now you can run your dotgit
from anywhere. Aliases will remain even with terminal/machine restarts.
git config --global core.excludesfile ~/.gitignore_global
git config --global core.excludesfile "$Env:USERPROFILE\.gitignore_global"
https://stegosaurusdormant.com/bare-git-repo/
https://www.atlassian.com/git/tutorials/dotfiles
https://opensource.com/article/19/7/bash-aliases
https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration