Stage and commit precisely
Turn a messy working tree into two or three clean commits: stage whole files when the change is one thing, stage single hunks when it is not, write a message that reads well in History, and amend when you got it slightly wrong.
Read the Changes view
Press ⌘1. The list on the left has up to three groups: Conflicted, which appears only during a merge or rebase; Not staged, with a "Stage all" link; and Staged, with "Unstage all". Click a file and its diff fills the middle. The commit box sits under the list.
A file that is partly staged carries a "Partly" badge and appears in both groups, because Git sees two different diffs: what is staged, and what is left.
Stage whole files
- Select a file in Not staged. Read the diff.
- Press Space, click Stage on the row, or click "Stage file" at the top of the diff. Double-clicking the row does the same.
- Repeat for every file that belongs in this commit. "Stage all" takes the lot when the whole working tree is one change.
- Staged something by mistake? Select it in Staged and press Space again, or click "Unstage file".
↑ and ↓ move through the list, so stage, stage, skip, stage is a few keystrokes.
Stage single hunks
When one file holds two unrelated changes, split it by hunk.
- Select the file. When the diff has more than one hunk, or the file is partly staged, each hunk header gains a "Stage hunk" button.
- Click "Stage hunk" on the hunks that belong to this commit. The file moves to Staged with the "Partly" badge, and the hunks you skipped stay in Not staged.
- Select the file under Staged to review exactly what will be committed, and "Unstage hunk" anything that slipped in.
Mergepond stages by hunk, not by line. If a single hunk mixes two changes, make the second change in your editor after the first commit, or split the hunk by adding a blank line between the parts.
Write the message and commit
- Click the commit box, whose placeholder reads "Summary of the change", and type the first line: what the change does, in the imperative, under about sixty characters. Press ⏎ for a blank line and then the why, if the first line cannot carry it.
- Check "Committing as" under the box. That is the name and email the commit will carry; click it to change the identity for this repository.
- Press ⌘⏎, or click "Commit 2 files". The number is the staged files.
The button refuses rather than guessing. With nothing staged it says "Stage a file or a hunk first."; with an empty message, "Write a commit message first."; mid-conflict, "Resolve the conflicts first." If the repository's workspace expects a different identity, a dialog asks "Commit with the expected identity?" before anything is written.
Amend the last commit
- Stage whatever you forgot, or nothing if only the message needs work.
- Tick "Amend" next to the commit box. If the message field is empty it fills with the last commit's message for you to edit.
- Press ⌘⏎. The button reads "Amend last commit", or "Amend with 1 file" if you staged something.
Amending rewrites the last commit, so only do it to a commit you have not pushed. For anything older, Rebase by dragging does the same job for a whole series.
Put a change aside
When something unrelated interrupts, "Stash all changes" from the toolbar, Repository › Stash All Changes or the palette puts every change in the working tree into a stash; the toast reads "Stashed 4 changed files. The working tree is clean." Stashes list in the sidebar with Apply, Pop and Drop. Pop restores and deletes the stash; Apply restores and keeps it.
If the interruption is more than a few minutes, a worktree is the better tool: it leaves this folder exactly as it is. See the Git worktrees tutorial.
Get more from it
- The diff header has Blame and History buttons for the selected file, so you can check who last touched a line before you change it.
- "No changes. Everything is committed." is the empty state of the Changes view. If you expected changes, check which worktree you are in; ⌘P lists them.
- A commit's first line is what History shows in the Description column. Write it to be read there, among a hundred others.
- The toast that reports a commit carries an Undo button for a few seconds. Undo moves the branch back one commit and leaves the files staged, so a commit made a moment too soon costs nothing; the toast then reads "Undone: Commit."