Adding your .emacs to Mercurial / Git
Having my favorite .emacs settings available, in the tip of my “hg clone” command is precious. No more backups and no more “oh no, I have an older version in my usb stick”. And it’s easy!
First of all, you need a mercurial server. Or an account at http://bitbucket.org/. Of course the same procedure stands for git.
Then you create a new repository (let’s call it my-emacs).
After that, you must move/rename your .emacs.d/ directory to .emacs.d-old/ and clone your repository.
cd ~
mv .emacs.d/ .emacs.d-old
rm -R .emacs.d/
hg clone https://yourname@bitbucket.org/yourname/my-emacs .emacs.d
the last line is available for copy-past on bitbucket.
Then you copy all your files to the .emacs.d which is now under version control
cp .emacs.d-old/ .emacs.d -R
Now the only thing is missing is adding your .emacs file. There are two ways. One is creating a init.el and the other one is having a .emacs file that loads another one dot-emacs.el which is in your version-controlled .emacs.d/
So,
cp .emacs .emacs.d/dot-emacs.el
The .emacs which is outside of .emacs.d (thus not under version control, should have this line:
(load “~/.emacs.d/dot-emacs.el”)
And you are ready! If you need to ignore a directory (which is inside .emacs.d/) just create a .hgignore file inside .emacs.d/ and add the name of the directory or any other files (google “hg ignore”):
ignore-dir/
Finally commit everything and push them to server.
cd .emacs.d
hg add *
hg commit -m “First commit”
hg push
Enjoy!