Cherry-pick, revert and reset
These actions work on commits you select in the graph: copy them onto a branch (cherry-pick), create a commit that undoes one (revert), move the current branch to a commit (reset), or check a commit out without a branch.
Most of them start from the commit context menu: right-click a row in the graph, or press Shift+F10 or the context-menu key on the selected row. While a merge, rebase, cherry-pick or revert is in progress, the cherry-pick, revert and reset items are disabled (Finish or abort the operation in progress first).
Cherry-pick commits
Section titled “Cherry-pick commits”A cherry-pick applies the changes of existing commits as new commits on the current branch (git-cherry-pick).
One commit
Section titled “One commit”Right-click the commit and choose Cherry-pick onto {branch}, where {branch} is the checked-out branch, or HEAD when detached.
Several commits
Section titled “Several commits”- Select the commits in the graph: ⌘-click (Ctrl-click on Windows and Linux) to add or remove one, Shift-click or Shift+↑/Shift+↓ for a range.
- The selection bar shows {count} commits selected. Click Cherry-pick {count} commits onto {branch} in the bar, or right-click inside the selection and choose the same item.
Esc collapses the selection back to one commit.
The commits are applied oldest first, whatever order you selected them in. Duplicates are ignored.
Drag commits onto a branch
Section titled “Drag commits onto a branch”Drag a commit row (or a row of the current multi-selection, which drags the whole selection) onto a local branch in the sidebar or on a branch label in the graph. The drop menu offers Cherry-pick this commit onto {target} or Cherry-pick {count} commits onto {target}, with the hint Checks out {target} first when the target is not the current branch. yaggui checks out the target, then cherry-picks. If local changes prevent that checkout, the checkout dialog opens and the cherry-pick does not run.
From the palette
Section titled “From the palette”Cherry-pick the selected commits applies the graph selection onto the current branch. With nothing selected, it shows Select a commit in the graph first.
What runs
Section titled “What runs”There is no confirmation. yaggui runs:
git cherry-pick [-m <parent>] <sha1> <sha2> …Toast: Commit cherry-picked onto {target} or {count} commits cherry-picked onto {target}.
Picking a merge commit needs a parent: yaggui opens the parent dialog.
Revert a commit
Section titled “Revert a commit”A revert creates a new commit that undoes the changes of an existing one (git-revert).
Right-click the commit and choose Revert this commit, or run Revert the selected commit from the palette (it uses the selected commit). For an ordinary commit there is no confirmation; yaggui runs git revert --no-edit <sha> and shows {sha} reverted.
Revert or cherry-pick a merge commit
Section titled “Revert or cherry-pick a merge commit”A merge commit has several parents, so Git needs to know which side to keep. yaggui opens a dialog:
- Revert merge {sha}: “A merge has several parents. Choose the one whose side is kept: the revert undoes what the other side brought.”
- Cherry-pick merge {sha}: “A merge has several parents. Choose the one the changes are computed against.”
Under Parent kept, each option shows Parent {n}, its short SHA and its summary. Parent 1 is selected by default and is “Usually the branch the merge was made on”; the others are “Usually the branch that was merged in”. The dialog previews git revert -m <n> <sha> or git cherry-pick -m <n> <sha>. Click Revert or Cherry-pick.
Reset the current branch
Section titled “Reset the current branch”A reset moves the current branch to another commit (git-reset).
- Right-click a commit, open Reset {branch} to here and pick Soft (Keeps all changes staged), Mixed (Keeps changes, unstaged) or Hard (Discards local changes). The dialog opens with that mode selected.
- Or run Reset the current branch to the selected commit… from the palette. The dialog opens on Mixed.
The dialog Reset {branch} to {sha} reads: “Moves the current branch to this commit. Choose what happens to your changes.” It works on a detached HEAD too ({branch} is then HEAD).
It first checks what would change (Checking what would change…) and summarizes the effect on the branch:
- {branch} loses {count} commits (still in the reflog).
- {branch} moves forward by {count} commits.
- {branch} already points to this commit.
Then choose a Reset mode:
| Mode | What happens |
|---|---|
| Soft | Only the branch moves. The undone commits’ changes stay staged, ready to commit again. |
| Mixed | The branch and the index move. Your changes stay in the working tree, unstaged. |
| Hard | The branch, the index and the working tree all take this commit’s content. Local changes are lost (saved to a backup first). |
For Hard, the dialog lists the files that lose their local content, each with what happens to it:
| Note | Meaning |
|---|---|
| changes discarded | A tracked file with local changes (or in conflict) |
| will be deleted | A file you added that does not exist in the target commit |
| comes back | A file you deleted that exists in the target commit |
| overwritten | An untracked file that the target commit tracks |
Untracked files that the target does not have are left alone and not listed. Under the list: These files are saved to a backup before the reset. If nothing would be lost, the dialog says No local change would be lost.
The dialog shows git reset --<mode> <sha> and is the confirmation: click Reset (soft), Reset (mixed) or Reset (hard). The button is available once the check has finished. yaggui runs git reset -q --<mode> <sha> --, after copying the listed files to a backup for a hard reset. Toast: Reset ({mode}) to {sha}, plus Local files saved to a backup first. when a backup was made.
Check out a commit (detached HEAD)
Section titled “Check out a commit (detached HEAD)”Right-click a commit and choose Checkout this commit. yaggui runs git switch --detach <sha> and shows HEAD is now detached at {sha}. No branch is checked out any more; commits you make are not on any branch until you create one (Create branch here…). See detached HEAD.
If local changes are in the way, the checkout dialog opens: see Branches.
Errors
Section titled “Errors”| Message | What to do |
|---|---|
| “{short} brings no change any more (it is probably already applied): skip it.” | The commit is already in the branch. The cherry-pick or revert stays in progress; click Skip in the toast or the banner, or Abort |
| “{short} is a merge commit: choose which parent’s side to keep.” | yaggui opens the parent dialog |
| “Parent {n} does not exist for {short}.” | Choose an existing parent |
| “There is no commit to apply them on yet.” | The repository has no commit: make a first commit |
| “Your local changes would be overwritten by the cherry-pick. Commit or stash them first.” (same for revert) | Commit or stash them. Show changes in the toast opens them |
| “Another operation (merge, rebase, cherry-pick, revert or bisect) is in progress: continue or abort it first.” | Finish it from the banner |
When Git stops on conflicts, the cherry-pick or revert stays in progress: resolve the files, then Continue, Skip or Abort. See Resolve conflicts. Other messages are in Error messages.
| Operation | Undo label | What undo does |
|---|---|---|
| Cherry-pick that completed in one go | cherry-pick of {count} commits | Moves the branch back with git reset --keep |
| Revert that completed in one go | revert of {sha} | Same |
| Soft reset | soft reset to {sha} | Moves the branch back |
| Mixed reset | mixed reset to {sha} | Moves the branch back and restores the index |
| Hard reset | hard reset to {sha} | Moves the branch back and writes the backed-up files back |
| Checkout of a commit | checkout of {sha} (detached HEAD) | Switches back to the previous branch or commit, keeping local changes |
A cherry-pick or revert that stopped on conflicts and was finished with Continue cannot be undone. See Undo and redo.