3

The docs say to keep the .emacs file in the HOME directory.

I'd like to share the file between multiple computers using a git repo. What is the best way to structure the repo without including everything else that's in HOME.

Do I have to turn HOME itself into a repo and include everything else in the directory in the .gitignore?

  • 2
    The docs you've linked to say "the init file may also be called .emacs.d/init.el. Many of the other files that are created by lisp packages are now stored in the .emacs.d directory too, so this keeps all your Emacs related files in one place", which essentially answers your question. – phils Oct 3 at 23:29
  • good point, I was reading that as "emacs may call the file" instead of "you may call the file .emacs.d/init.el and emacs will run from that" – Hugh_Kelley Oct 4 at 12:28
4

There is no need to to turn your whole home into a repo. .emacs.d will be enough, and cloning it whatever you go will do it too.

Supposing that your .emacs.d is a repo, to do that your .gitignore should look like:

/*
!init.el
!.gitignore

First line tells git to ignore everything, second line tells git that init.el shouldn't be ignored. Third line prevents git from ignoring the .gitignore. More info here.

Notice that if you ignore a subdirectory you won't be able to "unignore" files under it this way. Instead, use a .gitignore file specific to that subdirectory.

  • awesome, that was basically my plan except that I didn't know about !. Was going to commit just .emacs.d/init.el and then add ignore everything. – Hugh_Kelley Oct 3 at 21:31
  • 3
    I can't imagine why you would want to include only your init.el file in your repository. I would recommend that you use a 'normal' .gitignore approach of explicitly ignoring the things you don't want, and committing everything else. – phils Oct 3 at 23:27
  • @phils being in the need of including more things, or just split init.el into a set of manageable files, will inevitably happen sooner or later. – Muihlinn Oct 3 at 23:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.