History
Edit message, drop and move commits
8 min read
To change a single commit, you don't need to open the interactive rebase screen: the commit's menu has the most common edits. Each one is an interactive rebase done under the hood, with the to-do list prepared by Versora itself.
Which commits can be edited. These features apply to simple commits (that aren't merges) on the current branch's line, that is, the commits you reach from HEAD by following the first parent. On a commit from another branch, on one side of a merge or on a merge commit, the items show up disabled.
Commits already pushed. All the features on this page rewrite history: the edited commit and all the ones after it get new SHAs. If they were already on the remote, the next push has to be forced (see Force push).
Changes the message (summary and description) of any commit on the current branch, including an old commit. The commit's content doesn't change.
- The commit's menu › Edit commit message…
- The current branch's menu › Edit commit message… (applies to the commit at the tip of the branch).
- To edit several messages at once, use the Reword action of the interactive rebase.
- In the graph, right-click the commit, for example
b2c3d4e Validate email on login. - Choose Edit commit message….
- The "Edit commit message" dialog opens with the current message split into Summary and Description. On a commit that isn't the top one, it shows the rewrite warning.
- Adjust the text and click Save message.
- While it runs, the bar shows "Editing commit message…". At the end, the commit and the ones above it show up in the graph with new SHAs.
If you save without changing anything, nothing happens.
| Option | What it does | Default |
|---|---|---|
| Summary | The first line of the message. Required. | The current summary |
| Description | The body of the message, after a blank line. Can be left empty. | The current description |
An interactive rebase from the commit's parent, in which Versora replaces pick with reword in
the list and delivers the new message in place of git's editor:
git rebase -i --rebase-merges --autostash b2c3d4e^
# in the to-do list: "pick b2c3d4e Validate email on login" becomes "reword b2c3d4e ..."
# on the repository's first commit: git rebase -i --rebase-merges --autostash --root
--autostash puts the uncommitted changes away first and gives them back at the end.
--rebase-merges preserves any merges above the commit. Even for the top commit this is the path;
to add what is staged to the last commit, use amend.
Ctrl+Z ("Undo: Edit commit message") takes the branch back to the previous commits, with the old message. Because undo also restores the files, it requires a clean working directory.
- "This rewrites history: this commit and the ones after it get new IDs. If they were already pushed to the remote, you'll need to force push.": shows up in the dialog when the commit isn't the top one.
- "The message can't be empty.": the summary is required.
- "commit b2c3d4e isn't in the rebase list": git didn't include the commit in the list (the branch changed outside the app, for example). Refresh the graph (F5) and try again.
No preference or policy key changes this feature. The dialog doesn't check the team's message rules
(.versora.yml) or the Conventional Commits standard, which apply in the commit box (see
Conventional Commits): check the message yourself.
- Interactive rebase
- Amend: amending the last commit
- Commit surgery: "Amend this commit with the staged changes…" changes the message and the content of a commit in the middle.
Removes a commit from the current branch's history. The changes it brought no longer exist on the branch; the commits above are reapplied without it.
Use it when the commit shouldn't exist (debug logging, a forgotten test file) and hasn't been pushed yet. If it's already on the remote and other people have fetched it, prefer revert, which cancels out the commit without rewriting anything.
- The commit's menu › Drop commit…
- Several at once: see the "Drop several commits" section, right below.
- On the interactive rebase screen: the Drop action (the D key).
- Right-click the commit, for example
c3d4e5f Add debug logging. - Choose Drop commit….
- Check the "Drop commit" confirmation: "Remove "Add debug logging" (c3d4e5f) from history? Its changes will no longer exist in the branch." and the rewrite warning.
- Click Drop commit. The bar shows "Dropping commit…".
git rebase -i --rebase-merges --autostash c3d4e5f^
# in the to-do list: "pick c3d4e5f ..." becomes "drop c3d4e5f ..."
If a commit above depends on the lines the dropped commit changed, the rebase stops at a conflict. The "Rebase in progress" bar shows up in the changes panel: resolve it and click Continue, or click Abort to leave everything as it was (see Operation in progress).
- It finished without stopping: Ctrl+Z ("Undo: Drop commit") brings the commit back, with the previous SHAs.
- It stopped at a conflict: Abort puts everything back. If you resolved it and continued until the end, the operation goes into Ctrl+Z as a whole when it finishes ("Undo: Drop commit"), and undo brings the commit back. The dropped commit also remains in the reflog, in case Ctrl+Z refuses because the repository changed afterwards.
- "This rewrites history: this commit and the ones after it get new IDs. If they were already pushed to the remote, you'll need to force push.": it's part of the confirmation.
- The item is disabled on merge commits and on commits outside the current branch's line.
- Revert: cancelling out a commit that has already been pushed.
- Reset: removing the branch's last commits all at once.
- Commit surgery: "Uncommit…" removes the commit and brings its changes back to the stage, instead of throwing them away.
Drops several commits chosen in the graph at once. They don't need to be neighbors.
- Select the commits with Ctrl+click or Shift+click and open the selection menu › Drop 2 commits… (the number follows the selection). See Multiple selection.
- In the graph, Ctrl+click
c3d4e5f Add debug loggingande5f6a7b WIP. - Right-click one of the selected commits and choose Drop 2 commits….
- The "Drop 2 commits" confirmation asks "Remove them from the history of feature/login? Their changes will no longer exist on the branch.", lists the commits (up to six; the rest becomes "• … and N more") and shows the rewrite warning, with the count of those already on the remote.
- Click Drop 2 commits. At the end, "Dropped 2 commits." appears.
It's the same engine as the interactive rebase: a
git rebase -i from the parent of the oldest commit in the selection, with drop on the chosen
ones and pick on the others.
git -c rebase.abbreviateCommands=false -c rebase.updateRefs=false \
-c rebase.missingCommitsCheck=ignore -c rebase.rebaseMerges=false \
rebase -i --autostash --no-autosquash --empty=drop --no-fork-point c3d4e5f^
# to-do list: drop c3d4e5f / drop e5f6a7b / pick d4e5f6a
Unlike the single-commit item, this path refuses merges in the range (instead of preserving them).
Ctrl+Z ("Undo: Drop 2 commits") brings the commits back. If the rebase stopped at a conflict, Abort puts everything back; if you took it to the end, it goes into Ctrl+Z as a whole when it finishes.
When the selection doesn't work, the item shows the reason ("Drop 2 commits… — reason"):
- "an operation is in progress": finish or abort the stopped merge, rebase, cherry-pick or revert.
- "the selection includes a stash": take the stash out of the selection.
- "some commits aren't on feature/login": only commits on the current branch's line can be dropped.
- "there's a merge in the range": there's a merge between the oldest chosen commit and HEAD.
- "The selection is no longer on the current branch. Refresh the graph and select again.": the branch changed after you made the selection.
- Multiple selection
- Squash: combining the selected commits instead of dropping them.
Swaps a commit with its neighbor. "Down" swaps it with the previous (older) commit; "up", with the next (newer) one. It's for putting two commits in the order that best tells the story, or for placing a commit right above the one it's going to be combined with.
- The commit's menu › Move commit down
- The commit's menu › Move commit up (only shows up when there's a commit above it on the branch).
- To move several positions at once, use the interactive rebase (Alt+↑ and Alt+↓) or drag the commit.
- Right-click the commit, for example
d4e5f6a Fix typo on the login screen. - Choose Move commit down (or Move commit up).
- The swap runs right away, without confirmation; the bar shows "Moving commit…".
git rebase -i --rebase-merges --autostash c3d4e5f^
# in the to-do list, the "pick c3d4e5f" and "pick d4e5f6a" lines swap places
If the two commits touch the same lines, the swap can stop at a conflict; resolve it and continue, or abort (see Operation in progress).
Ctrl+Z ("Undo: Move commit") restores the previous order. If the swap stopped at a conflict and you took it to the end, it goes into Ctrl+Z as a whole when it finishes; if aborted, nothing goes in (the order is already back).
- The item is disabled when the neighbor is a merge commit, or when the commit isn't on the current branch's line.
- "the commits aren't adjacent (there's a merge between them)": git found a merge between the two in the to-do list.
- "The commits aren't on the same line of history.": the two commits aren't on the same path of the history.