Created
July 7, 2013 21:28
-
-
Save justinhj/5945047 to your computer and use it in GitHub Desktop.
Allows you to use dired to add multiple files to a git repository. This is useful since staging files in magit is sluggish and takes a long time when you have a lot of files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun git-add-files(files) | |
"Run git add with the input file" | |
(interactive) | |
(shell-command (format "git add %s" files))) | |
(defun dired-git-add-marked-files() | |
"For each marked file in a dired buffer add it to the index" | |
(interactive) | |
(if (eq major-mode 'dired-mode) | |
(let ((filenames (dired-get-marked-files)) | |
(files "")) | |
(dolist (fn filenames) | |
(setq fn (shell-quote-argument fn)) | |
(setq files (concat files " " fn))) | |
(git-add-files files)) | |
(error (format "Not a Dired buffer \(%s\)" major-mode)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment