5

I'm keeping my config-files in a git repository to use it on multiple different machines. I'm using the emacs package manager, but I don't want to add the packages to git, because which packages have to be available differs from machine to machint.

Short question: which folders and files do I have to exclude from the repository?

3
  • There is lots of Emacs users sharing their configuration on Github. For example, this is mine. Basically, you put under version control, all your configuration, and you exclude all the rest.
    – Nsukami _
    Feb 23, 2017 at 11:12
  • Sorry to say that, but your answer is not at all helpfull. I know how to put my config into git - it's there since ages. I would like to know: which paths do I have to exclude when I don't want to commit stuff of the package manager? I.e.: the repositories, the list of installed packages (if there is such a list) and the packages themselves.
    – Markus
    Feb 23, 2017 at 13:44
  • Sorry if I was not clear enough, when I said "your configuration", I was trying to say "all the *.el files you wrote, and all the folders you created to organize those *.el files". Everything else, not written/created by you, can be can or may be excluded.
    – Nsukami _
    Feb 23, 2017 at 14:33

3 Answers 3

2

Packages installed via the Emacs package manager are stored in the elpa directory. If you exclude that directory you won't have any package files in your git repository.

The only other consideration is that you may need to modify your init file, in case there's code in there that requires packages only available on one or the other of your machines. If that's the case, you'll need to do something like:

(when (string= (system-name) "my-home-computer")
      <code that only runs on your home computer>)

Beyond this, some packages may create files or directories in ~/.emacs.d/, but there's no general rule that would allow you to identify them. However, when this happens it's usually a way for the package to store data that is used by the package code, but not any actual code. Storing these files in git won't cause you any problems.

For example, in my ~/.emacs.d/ I have a directory created by auctex, which contains style information used by auctex in different situations. If that file got synced to a computer that didn't have auctex, it wouldn't cause any problems, as no other code would use it. (auctex may not be a great example as I think it's installed by default)

I also have a snippet directory created/managed by the yas-snippet package, which is similarly inert on a machine that doesn't have yas-snippet installed.

If you're really concerned about space, you need to go through your ~/.emacs.d/ directory 'by hand' and figure out where everything there came from. But in practice, only ~/.emacs.d/elpa has any real impact on what gets loaded and used by emacs packages.

2
  • Thank you, so I'll exclude the elpa directory. Nothing more?
    – Markus
    Feb 23, 2017 at 14:04
  • See my updated answer
    – Tyler
    Feb 23, 2017 at 14:18
1

Additional to the answer of @Tyler you may also like to exclude:

*.elc
#*#
*~
abbrev_defs
bookmarks

Always keep an eye on files that changed in the repository. If there occurs something not written by you it is candidate to exclude.

1
  • Agreed - these aren't related to packages per se, but it's a good idea to exclude them anyways
    – Tyler
    Feb 23, 2017 at 14:31
1

I have a directory in .emacs.d that I store all my version controlled information.

.emacs.d/home/emacs_config/

In that folder I have all my .el files including init.el Then I create a soft link in .emacs.d/ so init.el is loaded. init.el -> home/emacs-config/init.el

This adds my directory to load path:

(add-to-list 'load-path (substitute-in-file-name "$HOME/.emacs.d/home/emacs-config/"))

I also use a custom file to reduce clutter in init.el

(setq custom-file "~/.emacs.d/home/emacs-config/custom.el")
(when (file-exists-p custom-file)
   (load custom-file :noerror))

My .emacs.d/home has other folders too (system, org-files, etc)

Whenever I change machines I just bring my .emacs.d/home and I'm ready to go after the package manager installs all my required packages. That way I keep track of what I need instead of keeping track of what I'm ignoring. As you add more packages your ~/.emacs.d/ will become more and more cluttered (I have about 25 different files and directories right now).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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