Git Bare Repository - A Better Way To Manage Dotfiles

preview_player
Показать описание
I've been looking for a better way to manage my dotfiles. My old method involved moving all of my dotfiles into their own directory and then symlinking each one of them back into the directory structure. What a headache!

Using git bare repositories, there is no more moving files into an initialized git repository and then creating symlinks. Now, I just add, commit and then push. Done.

Want to make your own git bare repository? First, make a directory for your new git bare repository (I created one called "dotfiles" but you can name it whatever).

Then I entered the following in the terminal:

git init --bare $HOME/dotfiles
alias config='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME' (add this alias to .bashrc)
bash

Basic usage example:

config add /path/to/file
config commit -m "A short message"
config push

WHAT'S THE REASON FOR THE GIT BARE REPO?

By using the git bare repo, you can have nested git repos in your home directory and there will not be any issue with keeping things straight. That is the reason for the git bare repo and having an alias ("config").

ARTICLE REFERENCED IN THE VIDEO:

💰 WANT TO SUPPORT THE CHANNEL?

👕 BUY SHIRTS AND MUGS:
Help support this channel by purchasing these fine t-shirts, hoodies and mugs.

🗨️ JOIN ME ON DIASPORA AND MASTODON:

📁 MY CONFIGS:

Your support is very much appreciated. Thanks, guys!
Рекомендации по теме
Комментарии
Автор

New to github and using git to manage my dotfiles, suckless builds, etc... basically the stuff I’m tired of making from scratch each time I move to a new system. 😂

I’ve had to watch this video a few times to really understand how this is working.. Now that I understand I just have to say this is the most elegant and clean solution I’ve seen. Much better than GNU/stow or traditional methods.

Excited to soon be living in a world where I can git-clone a github repo on a brand new system and have everything be how I like it, from window manager to vim rc.

Thanks for this video. Really appreciate what you’re doing @distrotube 🙏🏻



Also- my dads side of the family all lives in West Monroe. He has a house out there on the same land as his brother and step-dad. Beautiful place. I like it much more there than So Cal.

engageintellect
Автор

Lmao i used to tar these files and upload then onto mega like every week xD

AbduleeFtw
Автор

Awesome! I was just about to restart my dotfiles and was already dreading the symlinking management I would have. Thank you!!!

lpanebr
Автор

imo you should retitle this video

That the clone is bare isn't really important here-- all it means is that wherever you clone (or initialize) it, Git will store all the repo metadata but not check out any version of the contents of the repo in that directory.

The real workhorse here is the git-worktree feature, and you can use it with any repo to create a working tree in another directory, and you can have as many of them as you want.

vpxc
Автор

Thanks for putting together this video! I read that article, and then searched on YouTube to see if someone could explain it better. Showing the normal repo and bare repo side by side was what I was looking for. Your explanation, and walking through actually using it made it make sense!

evanstenger
Автор

Nice. Well-edited and informed Linux content that’s useful for both new and experienced Linux users. Surprisingly rare on YouTube. Thank you!!

mitchelvalentino
Автор

Thanks a bunch. Excellent way to manage dotfiles. I'm quite good at git but i didn't know you could use it like this so much better than symlinking everything

RockTheCage
Автор

My .vimrc file has become one of the most valuable and irreplaceable files on my computer and having a backup is essential.
I've have a really inefficient git backup setup currently, but this video is exactly what I've been looking for for months.
Excited to implement it.
Especially now that I started using linux and I'm creating even more valuable/ irreplaceable dot files.

ItsRyanStudios
Автор

Tip: use 'exec bash' or 'exec zsh' as it works better than just sourcing the .bashrc .zshrc or launching a new instance of the shell within a shell. Especially if you are doing it a lot as you build your dotfiles.

matthewstott
Автор

Yeah this method is really awesome, I use it for some time now. Can't live without it.

distroverse
Автор

⚠️ BE CAREFULL EVERYBODY WHO'S GONNA USE THAT METHOD... ⚠️ I did 'config reset --hard' to my repo and that ALMOST killed all my configs. If you have done like that you still can get back to the last commit: check 'config reflog' and then 'git reset --hard ' back to the last commit.

wvovaw
Автор

Wow, this tutorial is very self-explanatory and very informational. Thank you sooo much! :)

miss-astronomikal-mcmxcvii
Автор

I am always learning something new every time I watch your show! Also, congratulations on your Saints winning on Sunday!

bobgrimes
Автор

Really cool of you to credit the author of the article you got the idea from, respect!

UNNAMD
Автор

but how would you clone in it in a fresh system?

fuseteam
Автор

thanks a lot! I knew there would be a solution like this. For some reason, I made my dotfile repos in the same way as it were in the home directory, having each filesin their corresponding directory folders and whatnot. surprisingly, after applying what you showed in your video, cloning from my repo was a breeze, and everything just fits perfectly after cloning! and it was indeed a hassle symlinking each one of them from their corresponding folder. but then I knew this can be done, which is indeed better than my first option, which is to turn the entire home directory as a git repo, which would be a hassle. I never knew this option can be done! really helped a lot!

meowtabby
Автор

I think this is the cleanest way to do this task. The neat part is that one can track dotfiles in root or nested folders at the same time.

gcasanas
Автор

DT, you should do a video on ' etckeeper ' straight from the default repos. A VCS for all of your etc config files, it keeps logs of all changes and it has its own set of commands which are actually very similar to git's. Its more automated, every time you update whether its APT or Pacman it lets you know all of the changes being logged in the output.

DDBAA
Автор

This video is excellent, by far this is my favorite method to manage dotfiles

SantiYounger
Автор

This is the most convenient method I've seen so far. Great video!

QazCetelic