How can I do this more efficiently, assuming I do this hundreds of times a day - it becomes tedious.

# while editing a source code file
M-x magit-stage-file
M-x magit-commit
type in wip
C-c to confirm

2 Answers 2


One way is to write a command that wraps those actions:

(defun anw/magit-commit-file-wip ()
    (let ((file (or (magit-current-file)
                    (user-error "No current file"))))
      (magit-stage-file file)
      (magit-run-git "commit" "--message=wip" "--" file))))

If you want to operate on tracked files only, you could drop the magit-stage-file call above. And if you want to include staged changes from other files in the commit, you can drop the file argument to git commit and add --all instead.

Also, you may want to have a look at both magit-file-popup and Magit's WIP modes if you don't already use them.


You can use the magit-status buffer. Run M-x magit-status, and a buffer will open showing the status of the project.

You can move point to the source file and press s to stage it -- or even move to just one chunk in the file to stage it but not other changes ih the file.

You can then commit with c c, and it'll prompt for the message. You can commit with C-c C-c.

Note that you can always have the magit-status buffer open; if you switch back to it and press g, it'll refresh to show you the latest status.

So the entire procedure is this:

C-x b *magit: project <ret> #or however you switch to the buffer
g #refresh the view
nnnn #move to the buffer you changed, assuming you're at the top of the buffer.
s #stage the changes in that buffer
cc #open the commit window
<write commmit message>
C-c C-c #commit it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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