Backup config files with git
In the home directory there are a bunch of config files that decided to backup them in case of whatever happen.
There are a lot config files especiall under
.config directory. For the beginning decided to backup the emacs configs
.emacs.d/ directory and the
.bashrc that includes mostly aliases.
When I am sshing at a vps I will be able to just clone the emacs config repository and voila.
So here is the receipt.
- Firstly initialize git repo for the emacs and copy them to different directories, because it is one directory with multiple repositories.
cd ~ git init cp -rf .git .git-emacs-config rm -rf .git
- And then the same for the bash configs
git init cp -rf .git .git-bash-config rm -rf .git
- Now we have to ignore everything except those files that we need. And we don’t have the luxury of .gitignore currently. So edit the
.git-emacs-config/info/excludeby appending the following
*~ .* * !.emacs.d !.emacs.d/* !.emacs
- And then do the same with
.* * !.bash_history !.bash_logout !.bash_profile !.bashrc !.zlogin !.zshrce
- The only difference now for the git command you have to run ```bash git –git-dir .git-emacs-config add . git –git-dir .git-emacs-config commit -m ‘first commit’ git –git-dir .git-emacs-config push to-your-server ``
Imagine that you can switching branches with different config flavors in an existing home directory, instead of create a new unix user if you want to try different configuration environments 🎉 🎊.