emacsgitignoreelpamelpa

Gitignore not ignoring elpa emacs folder


I'm not sure why the gitignore isn't working, but for some reason it continually tries to add the /elpa/ directory to version control. Here is my gitignore (in the root of my dotfiles repository)

*.swp
*.swo
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
.org-id-locations
*_archive
*_flymake.*
/eshell/history
/eshell/lastdir
/elpa/
*.rel
/auto/
.cask/
*.last
/elpa/*
/.emacs.d/elpa/*

Notice I tried 3 different elpas in here and none of them are working. Does anyone know why?

The directory structure is

|- configurations  
 - .gitignore
 |- dotfiles
   |- emacs.d
      | -elpa
      - init.el
      - etc

Solution

  • /elpa/ (starting with a '/') means it will only ignore the one at the level of the .gitignore.
    Not any elpa folder below that .gitignore file.

    elpa/ would ignore all elpa folders.
    (no need for elpa/*)

    From gitignore man page:

    A leading slash matches the beginning of the pathname.
    For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".