0

I've never really used vc but it looks like it only supports add or commit actions.

I reckon magit must have some of the machinery to achieve this, but browsing its codebase didn't reveal anything obvious.

2

I guess you don't want to:

  • first: call magit-status
  • second: press s to stage the file you want

So, let me suggest this function, courtesy of Nicholas Bishop:

(defun git-add-current-buffer ()
  "call 'git add [current-buffer]'"      
  (interactive)
  (let* ((buffile (buffer-file-name))
         (output (shell-command-to-string
                  (concat "git add " (buffer-file-name)))))
    (message (if (not (string= output ""))
                 output
               (concat "Added " buffile)))))

The next thing is probably set a custom shortcut for that function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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