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.
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).
- Open the directory: Open the folder containing your files in Dired (
C-x d). - Identify changes: Look for files marked with
M(Modified) orA(Added/Untracked). - Mark the files:
- Move your cursor to the file you want to include.
- Press
mto mark the file. - Repeat
mfor all files you want to include in this specific commit.
- Stage the files:
- Run
M-x vc-git-add. - Note: In some Emacs versions, if
vc-git-addisn't directly in your command list, you can useM-x shell-commandand typegit add -u(for modified) orgit add .(for all).
- Run
- Commit:
- Run
M-x vc-commit. - A new buffer will open for your commit message. Type your message, then press
C-c C-cto finish the commit.
- Run
If you want to see exactly what you are committing before you stage it:
- Open the Diff buffer: Run
M-x vc-diff. This opens a buffer listing all files that have changed in the repository. - Select files: This buffer acts like Dired. You can move your cursor to a file and press
mto mark it. - Stage the marked files:
- While in the
vc-diffbuffer, runM-x vc-git-add. This will stage only the files you have marked.
- While in the
- Commit:
- Run
M-x vc-commit.
- Run
| 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. |
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.