2021-01-25

If I want to create a symbolic link on Windows I have to explicitly allow a terminal to run as Administrator. Dotfiles management tools developed for Linux/MacOS and based on symlinks ( GNU-stow, rcm, ... ), without admin privileges, they will fall back to normal copies when they try to create a new symlink.

An approach based on a bare Git repository does not have this drawback instead. Moreover, it does not require new toolings since you only need to have Git installed.

Here are the steps that I have followed to manage my configuration files with a Gitlab repository from my MSYS2-MINGW64 command-line terminal:

1. I created an empty repo ( should be completely empty, no README or LICENSE file ) on Gitlab and prepended to the repo's 'slug' a dot.

2. Added the 'side directory' locally :

   $ mkdir .dotfiles

3. Initialised as 'bare' :

   $ git init --bare /c/Users/admin/.dotfiles

3. Added the following alias to my .bashrc file:

   alias dotfiles='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
   dotfiles config --local status.showUntrackedFiles no

4. Important, do not forget to source the .bashrc file.

5. Set the local repo to the remote repo:

   $ dotfiles remote add origin https://gitlab.com/Sevepy/.dotfiles

6. Stage and commit my dotfiles e.g.:

   $ dotfiles add .bashrc
   $ dotfiles commit -am "the bashrc"

7. First time upload to the remote repo:

   $ dotfiles push --set-upstream origin master
  Thereafter:
   $ dotfiles push 

You can also have a look at my dotfiles repo or at a similar workflow for Github.