Skip to content

Instantly share code, notes, and snippets.

@dotemacs
Created March 4, 2010 00:53
Show Gist options
  • Save dotemacs/321268 to your computer and use it in GitHub Desktop.
Save dotemacs/321268 to your computer and use it in GitHub Desktop.
;; creates .gitignore file
;;
;; added a check, so that if a .gitignore exists already it doesn't overwrite it
(defun gitignore(dir)
"create .gitignore file in a directory supplied
populating it with the patterns/files"
(interactive "DDirectory name: ")
(setq ignore-patterns
;; modify patterns/files below as per your need
'("*~"
"log/*.log"
"tmp/**/*"
"config/database.yml"
"db/*.sqlite3"))
(setq .gitignore (concat (file-name-as-directory dir) ".gitignore"))
(if (file-exists-p .gitignore)
(progn
(message "%s exists already, nothing new was added" .gitignore)
(find-file .gitignore))
(progn
(switch-to-buffer .gitignore)
(while ignore-patterns
(insert-string (concat (car ignore-patterns) "\n"))
(setq ignore-patterns (cdr ignore-patterns)))
(message "%s created" .gitignore))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment