How to manage dotfiles in Windows, yes you read that right, Windows.

Some backstory.

If you want to skip this section, click here.

I’ve been using VSCode on Windows for about two years, I’m new to programming and come from the construction industry as you can see on this website, I’m kind of tied to the Windows OS or as some people call it William G. Telemetry, also known as MS Telemetry, so switching to Linux is not an option.

Vim in the future?

I’ve been checking twitter lately and there’s a lot of talk about NeoVim and decided to give it a try, learn a bit more about it and of course the configuration side of it, and maybe one day I can replace VSCode.

I’ve used Vim to edit small text files, but nothing more, already mastered hjkl and :wq! and never needed anything else, so my learning path started by reading the Vim docs and the NeoVim docs, then started watching a video from TypeCraft and so far I’m happy with the results.

But after watching the first video he mentioned something about the dotfiles folder, and reading further about it I thought it would be a good idea to save my configuration to be used on other computers. So I decided to look for a solution.

There are some solutions like creating symbolic links, which are similar in Linux, but luckily searching on YouTube I found a video from the DistroTube, a channel I watch from time to time because of its professional lookng videos, (, in the video he shows a solution to manage the dotfiles using a git bare repository, so I watched the video, read the article that inspired his video and started on my way to create my dotfiles report.

Tutorial part

This is currently the best solution I’ve found, so if you find something better or know of another solution, please share it, I’d love to hear some ideas.

My setup

I’m using
– Cmder (, a portable console emulator, with cmd from Windows
– Git


I have two directories for this tutorial, the dotfiles directory with my files and a dotrepo directory.

The dotfiles directory is my working directory, usually in Windows the config files are stored in the C:\Users\

Be careful, there’s an AppData directory which may contain some other config files, in the Local and Roaming subdirectories, so check where your program stores the config files, and you have to take care of the subfolders using a .gitignore file, or you can add your dotfiles manually.

Run cmd, cmd or power shell as admin.

Inside the dotrepo directory run git init --bare, this will create a bare repository with no working tree, this is not a normal git directory because you won’t be adding files to it.

Now you can go into the dotfiles directory and add a file, in my case I added a *

Then run the following command
git –git-dir=D:\example\dotrepo\ –work-tree=D:\example\dotfiles\ status`.

You can see that the file we just created is shown as untracked.

The --git-dir= command tells git where the git naked directory is, and the --work-tree= command tells git where the working tree is.

The \”–git-dir=D:\example\dotrepo\” and “–work-tree=D:\example\dotfiles\” are all the magic in this process.

For example, we can add, commit and push the README
– git add
git commit -m "First file added"'
git push.
git status.

For example, you can configure your username, password, and URLs in your git bare folder using the same method

git config –local “
git config –local “
git config –local remote.origin.url “


When you use git status you will notice that everything in the folder will be listed as untracked, you have to add the files and folders manually, don’t add everything to wsing git.

Cmder aliases

If you don’t want to type the long commands every time you can use cmder aliases, and of course if you’re in the command prompt or using powershell you can add aliases too, I just prefer cmder because it’s easy to configure.

The file with the aliases can be found iside the cmder directory in …cmder\config\user_aliases.cmd

Let’s look at the alias in Cmder for our case.
dgit=git --git-dir=D:\example\dotrepo\ --work-tree=D:\example\dotfiles\ $*

Where dgit= is the alias name.
The magic is git --git-dir=D:\example\dotrepo\ --work-tree=D:\example\dotfiles\ and$*` tells cmder that flags can be added at the end of the command.

After editing and reloading the aliases in cmder, you can then run
`dgit status’ and you will get the status of the bare git repository.

Please note that if you do not add $* to the end of the alias, Cmder will ignore the flags that come after the command, i.e. you will only run the git command which shows the usage of git.


Manually added files

It takes time to search with configuration files or folders, and then they have to be added one by one to the repo.

Empty folders

I mentioned already but this has to be clear, you have to add the files and directories manually

For instance git add AppData\Local\nvim.

Add the files to the repository with the full path with empty directories, in my case some files are in C:\Users\AppData\Local\nvim, the configuration files for neovim are added to the repo as AppData\Local\nvim.

Other files

Configuration files outside C:\Users\ can’t be tracked using git, everything has to be in the work-tree.


Posted in

0 responses


Your email address will not be published. Required fields are marked *