8

I want to version control all the configuration files I have in my home directory on Linux machines. Files like

.bashrc
.bash_aliases
.bash_functions
.emacs
.gitconfig
.profile

Then I could just clone the repo into my home directory on any computers I had to do work on, and keep nifty emacs macros or bash functions I create up to date on all my servers. GitHub has a lot of features that make it an attractive solution for this, but I can't clone repos into existing directories, which is a problem.

What is a good way to manage these files across all the computers I use?

random
  • 9,774
  • 10
  • 66
  • 83
TJ Shah
  • 435
  • 4
  • 17

1 Answers1

15

So the approach I use, and a lot of others use, is to have a dotfiles folder. In here you keep your .bashrc, .vimrc, etc. and create a repo of that folder. Clone this folder to all your machines, and soft link to the files using the ln command.

cd ~
mkdir dotfiles

mv .bashrc dotfiles/
#move other files

ln -s dotfiles/.bashrc .bashrc
#link other files

#do the git stuff
John Mellor
  • 12,572
  • 4
  • 46
  • 35
Dale Myers
  • 2,703
  • 3
  • 26
  • 48
  • Just to be clear, you have to do the soft link on each machine for each dot file once, correct? – Yousuf Azad Feb 28 '19 at 09:05
  • 1
    Yup, that's correct. – Dale Myers Feb 28 '19 at 13:02
  • And I have to delete/move the `~/.bashrc` and other dot files first from their original location, right? – Yousuf Azad Mar 01 '19 at 08:22
  • It depends on what you are looking for and what the tool is. For a basic config file, yes. But for your `.bashrc`, if you want to keep it, you can just add `source /path/to/dotfiles/bashrc` at the end and it will handle both. – Dale Myers Mar 01 '19 at 12:02