Skip to content

Instantly share code, notes, and snippets.

@leighklotz
Last active April 5, 2026 00:53
Show Gist options
  • Select an option

  • Save leighklotz/8533118f5d3f755e374518f739d3fd3b to your computer and use it in GitHub Desktop.

Select an option

Save leighklotz/8533118f5d3f755e374518f739d3fd3b to your computer and use it in GitHub Desktop.
git emacs multfiile commit

In vanilla Emacs (without Magit), the vc (Version Control) library acts as a thin wrapper around Git. Unlike Magit, which has a specialized "staging" workflow, vanilla vc follows the standard Git logic: you must add files to the index (stage them) before you commit them.

Here are the two best ways to do this using only built-in features.

Method 1: Using Dired (Best for multiple files)

If you have many files to commit, the most efficient way is to use vc-dir (which is just Dired with version control information enabled).

  1. Open the directory: Open the folder containing your files in Dired (C-x d).
  2. Identify changes: Look for files marked with M (Modified) or A (Added/Untracked).
  3. Mark the files:
    • Move your cursor to the file you want to include.
    • Press m to mark the file.
    • Repeat m for all files you want to include in this specific commit.
  4. Stage the files:
    • Run M-x vc-git-add.
    • Note: In some Emacs versions, if vc-git-add isn't directly in your command list, you can use M-x shell-command and type git add -u (for modified) or git add . (for all).
  5. Commit:
    • Run M-x vc-commit.
    • A new buffer will open for your commit message. Type your message, then press C-c C-c to finish the commit.

Method 2: Using vc-diff (Best for reviewing changes)

If you want to see exactly what you are committing before you stage it:

  1. Open the Diff buffer: Run M-x vc-diff. This opens a buffer listing all files that have changed in the repository.
  2. Select files: This buffer acts like Dired. You can move your cursor to a file and press m to mark it.
  3. Stage the marked files:
    • While in the vc-diff buffer, run M-x vc-git-add. This will stage only the files you have marked.
  4. Commit:
    • Run M-x vc-commit.

Summary of Key Commands

Task Command Note
Stage New Files M-x vc-add Use this for files that don't exist in Git yet.
Stage Modified Files M-x vc-git-add Use this to move "Modified" files to the index.
View all changes M-x vc-diff Great for a "birds-eye view" of what's changed.
Commit M-x vc-commit Opens the commit message buffer.
Finalize Commit C-c C-c The standard way to save and exit a commit buffer.

Pro-Tip for Emacs 29/30 users

If you find yourself doing this often and want a "Magit-lite" experience without installing heavy packages, you can use the built-in M-x compile or M-x shell-command to run git add . quickly.

However, the Dired + m + vc-git-add workflow is the most "pure" Emacs way to handle multiple files without leaving the buffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment