DEV Community

Cover image for Easiest way to store dot files using git!
Sajjat Hossain
Sajjat Hossain

Posted on

3 4

Easiest way to store dot files using git!

I was looking for a long time for a solution that will help me to store my dot files on a git remote repository. I found sylink method but that was a very lengthy process. I had to manually create all sym-links. Which is not that intuative. Then one day i came accross a youtube video by DistroTube, where he explained how we can store our files using git bare repository. I'll try to explain here how to do it and if you wanna check his video I'll leave a link at the bootm.
Here's the process:

Create a bare repository in the home folder :

$ mkdir dotfles
$ git init --bare $HOME/dotfiles
Enter fullscreen mode Exit fullscreen mode

Now run these commands :

$ alias dotfiles='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME'
$ dotfiles config --local status.showUntrackedFiles no
Enter fullscreen mode Exit fullscreen mode

Note:

  1. The first command will add dotfiles alias to the .bashrc file. So, that we dont have to type the line all the time which is crucial for the process.
  2. The second line will prevent any promt created because of untracked file.

Now you are good to go. You can add files just as you add using git command. Instead use the alias. Just do as shown below :

First let's add the remote repository link (If it's the first push):

$ dotfiles remote add origin <repository_link>
Enter fullscreen mode Exit fullscreen mode

Let's add a file or folder ( first locate the file/folder ) :

$ dotfiles add <pathToTheFile/fileName>
$ dotfiles commit -m "Test Commit"
$ dotfiles push -u origin <branch_name>
Enter fullscreen mode Exit fullscreen mode

Greate! You've seccessfully uploaded your dotfiles to git remote repository. Now when you change anything just add, commit and psuh just as shown.

Link to DistroTube's Video

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay