Review and stage changes
After finding and editing code, review what changed before preparing a commit. Mitos can show unsaved edits, files on disk, and Git’s staging area. Those versions can differ.
This walkthrough uses Git. Start in a repository with a tracked file that has
no uncommitted changes, and make a small edit using the techniques from the
earlier articles. For example, change a word in a comment with miw, c, the
new text, and Esc. Leave the edit unsaved for the first step.
Review your edit before saving
- Press
Space g dto compare the current buffer withHEAD, your checked-out commit. The review includes the unsaved edit. - Use
]gand[gto move between groups of changed lines, called hunks. Removed and added lines show the old and new text. - Press
Enteron an added or unchanged line to return to that location in the source file. You can also useCtrl-oto return through the jumplist.
The review is read-only. Opening it does not save the source file or stage anything. If you see an unintended change, return to the source and fix it, then review again. Current-file reviews update as the source changes.
For a quick look at one change, put the cursor on it in the source file and
press Space g i. Press Esc to close the popup.
Save, then stage the intended version
Staging chooses what goes into the next commit. It uses the file on disk, so save the version you want to include first.
- In the source buffer, run
:write. - After the save completes, press
Space g sto open the changed-file picker and select that file. - Press
Alt-sto stage it. Staging needs Git on yourPATHand workspace trust; use:workspace-trustfor a project you trust if Mitos asks for it. - Look at the staged and unstaged columns. For this exercise, the change should now be staged, with no remaining unstaged change in that file.
- Use
Alt-porAlt-nuntil the preview shows the staged comparison. This comparesHEADwith the version selected for the next commit. - Press
Alt-oto open that comparison in a review buffer.
Alt-s stages the entire file, not just the highlighted lines or current hunk.
It does not save unsaved buffer edits. If a file contains changes that belong
in separate commits, save it and use git add -p in your terminal to stage
selected hunks.
To undo a staging decision, reopen Space g s, select the file, and press
Alt-u. The saved file stays changed; only the staged version is reset.
Stage it again and inspect the staged comparison before committing.
Understand the three versions
| Version | How it changes | What to review |
|---|---|---|
| Buffer | You edit text in Mitos | Space g d compares HEAD with the buffer, including unsaved edits |
| File on disk | You run :write | :vcs-diff unstaged compares the staged version with the file on disk |
| Staging area | You stage the saved file | :vcs-diff staged compares HEAD with the staged version |
If you edit again after staging, your next commit still contains the previously
staged text. Save and stage again to include the new edit, or leave it unstaged
for a later commit. Use :vcs-diff buffer to compare the staging area directly
with your current buffer.
When the staged diff contains what you intend, make the commit in your terminal:
git diff --cached
git commit -m "Describe the change"
The commit contains staged changes throughout the repository, including files you staged earlier. Review that full diff even if you edited only one file in this exercise.
Find out why a line changed
History helps when an unfamiliar piece of code has a reason behind it:
- Put the cursor on an unchanged line and press
Space g b. The blame popup identifies the commit that last changed it and shows its message. - Press
Esc, thenSpace g fto browse commits that changed this file. - Read the preview, or press
Enterto open a commit’s diff. - Use
Ctrl-oto return through your earlier locations.
Browsing history opens read-only versions; it does not switch your branch or
replace working files. A line with uncommitted changes can show Not committed
yet rather than a previous commit. Use Space g l when you need the history
of the whole repository rather than one file.
Restore one experimental change
In the source buffer, place the cursor on the unwanted change and press
Space g i to inspect it. Press r in that popup to restore the inspected
hunk from HEAD, then check the result. Press u in the source buffer to undo
the restoration.
Restoration changes only the buffer. It neither saves the file nor updates the staging area. If you keep the restored text, save it and review the versions again before staging.
For the full command list and workflows for conflicts, stashes, branches, and worktrees, see Version control.
Previous: Navigate a project · Back to: Editing effectively