4

I want to stage a file or a hunk using vc-git (the vc system that comes with Emacs). How do I do this?

(To clarify, I made modifications on a file that is already (registered) in git. I would like to stage the new modifications made. How do I do this with vc-git?)

3
  • 1
    Have a look at vc-git-register, which does a little bit more -- the first argument needs to be in list form. If you want it to do less, then you may need to create a custom function. To see what makes it tick, you can use M-x find-function.
    – lawlist
    Nov 1, 2017 at 19:27
  • While VC has grown some features specifically for Git, it hasn't grown anything like Git's staging, so vc-git does not provide any means to manipulate Git's "index", instead it tries hard to hide it. You'll probably be better served by Magit if you want to use that kind of Git feature from Emacs.
    – Stefan
    Nov 29, 2019 at 16:02
  • @Stefan But one can stage and commit only marked files in vc-dir. Though it is not possible to stage hunks.
    – muffinmad
    Dec 1, 2019 at 11:05

1 Answer 1

4

C-x v v will run vc-next-action command.

Do the next logical version control operation on the current fileset. This requires that all files in the current VC fileset be in the same state. If not, signal an error.

For merging-based version control systems:

  • If every file in the VC fileset is not registered for version control, register the fileset (but don’t commit).
  • If every work file in the VC fileset is added or changed, pop up a *vc-log* buffer to commit the fileset.

Your Answer

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

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