.gitignore regex for emacs temporary files

前端 未结 6 1618
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 06:11

I\'m trying to .gitignore emacs temporary/autosave files. I\'m using...

\\.\\#.*

in my .gitignore.

But git add -A run in

6条回答
  •  星月不相逢
    2021-02-05 06:33

    To suppress the temporary Emacs files appearing on git status globally, you can do the following:

    1. Configure git to use a global excludesfile

      Since this is a common problem, git has a specific solution to that:

      Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig

      git config --global core.excludesfile ~/.gitignore_global    
      
    2. Create the respective file

       cd
       touch .gitignore_global
      
    3. Paste the following template into the file

      # -*- mode: gitignore; -*-
      *~
      \#*\#
      /.emacs.desktop
      /.emacs.desktop.lock
      *.elc
      auto-save-list
      tramp
      .\#*
      
      # Org-mode
      .org-id-locations
      *_archive
      
      # flymake-mode
      *_flymake.*
      
      # eshell files
      /eshell/history
      /eshell/lastdir
      
      # elpa packages
      /elpa/
      
      # reftex files
      .rel
      
      # AUCTeX auto folder
      /auto/
      
      # cask packages
      .cask/
      dist/
      
      # Flycheck
      flycheck_*.el
      
      # server auth directory
      /server/
      
      # projectiles files
      .projectile
      
      # directory configuration
      .dir-locals.el
      
      # network security
      /network-security.data
      
    4. Watch git do its magic! :)

提交回复
热议问题