Graph
Dragging branches and commits
13 min read
In the graph and in the left panel, several day-to-day operations are a drag: drop a branch onto another one to update it, merge or rebase; drop a local branch onto a remote to push it; drop commits onto a branch to cherry-pick them there; drop a commit onto another one to change a branch's base. Before running anything, Versora always shows what it's going to do: a menu with the possible actions (branches) or a window with the plan and the conflict prediction (commits).
| What you drag | From | To |
|---|---|---|
| A local branch | A row of the LOCAL (or GITFLOW) section of the left panel, or its label in the graph | Another branch (local or remote, in the panel or in the graph) or a remote's folder in the REMOTE section |
| A remote branch | A row of the REMOTE section or its label in the graph | A local branch |
| One or more commits | The commit's row in the graph (outside the BRANCH / TAG column) | A local branch label (in the graph or in the panel) or another row of the graph |
- Press the left button over the item and move the mouse. The drag starts after a few pixels: a simple click is still a click.
- A label follows the cursor. Over a valid target, the target is outlined and the label says "source → target" (for example "feature/login → main").
- Near the top or bottom edge of a list (graph or panel), it scrolls on its own so you can reach targets off screen.
- Drop it on the target. To cancel, press Esc before dropping or drop it outside a target.
- Dragging commits only starts with the left button without Ctrl, Shift or Alt: with them, the click changes the multiple selection.
- Dragging from a label drags the branch; dragging from the rest of the row drags the commit.
Dropping a branch (the source) onto another one (the target) opens a menu with what makes sense for both, worked out from the relationship between them: if the target is only behind, the offer is to move it forward (fast-forward); if the two have diverged, merge or rebase. Dropping a local branch onto a remote branch, or onto a remote's folder in the REMOTE section, offers the push.
| Drag | Items that can appear |
|---|---|
| Local branch onto local branch | Fast-forward main to feature/login, Merge feature/login into main, Rebase feature/login onto main |
| Remote branch onto local branch | The fast-forward and the merge (the rebase only applies with a local source) |
| Local branch onto a remote's folder | Push feature/login to origin |
| Local branch onto a remote branch | Push feature/login to origin/feature/login and, if the remote one has commits the local one doesn't, the merge and the rebase |
Each action goes through the same checks as the menus: the conflict prediction before merge and rebase and the checks before push. Fast-forward, merge and rebase go into Ctrl+Z as a single operation; push doesn't.
The full menu for each combination, the examples, the git command of each item, how to undo and the caveats are in Dragging branches.
Dropping a commit (or several selected commits) onto a local branch label cherry-picks them onto that branch. If the branch isn't the current one, the cherry-pick is done without checkout: the branch you're on and the open files don't change; only the target branch moves forward.
Drag a commit's row in the graph (or any commit of a multiple selection) onto a local branch label, in the graph or in the LOCAL section of the left panel. The label next to the cursor says "a1b2c3d Corrige o cálculo do frete → cherry-pick onto release/1.4" (with several commits, "3 commits → cherry-pick onto release/1.4").
- Select the commit (or the commits, with Ctrl+click) you want to take.
- Drag it onto the
release/1.4label and drop it. - The app builds the plan ("Building the plan and predicting conflicts…") and opens the Cherry-pick 2 commits onto release/1.4 window.
- Read the plan: which commits go in, from oldest to newest, on top of which commit; the ones left out; whether there will be a checkout; the conflict prediction.
- Click the main button (see the table) or Cancel.
The window's text and button change depending on the case:
| Case | Note in the plan | Button |
|---|---|---|
| The target is the current branch | "release/1.4 is the current branch: this is a regular cherry-pick; on a conflict it stops in the conflict editor." | Cherry-pick (or Cherry-pick anyway, with a conflict expected) |
| Another branch, no conflict expected | "No checkout: the current branch and your files stay as they are; only release/1.4 moves." | Cherry-pick |
| Another branch, conflict expected | "With a conflict, the cherry-pick needs a checkout: the app checks out release/1.4 and stops at the conflict for you to resolve." | Check out release/1.4 and cherry-pick |
| Another branch, old git | "This git can't cherry-pick without a checkout: the app checks out release/1.4 first." | Check out release/1.4 and cherry-pick |
Other notes that can appear:
- "1 commit is already in release/1.4 and is left out."
- "2 commits wouldn't change anything in release/1.4 (the changes are already there) and are left out."
- "You can undo it with Ctrl+Z."
The conflict prediction appears at the bottom of the text: "No conflicts expected.", or "Applying a1b2c3d (Corrige o cálculo do frete) will conflict in 2 files:" with the list of files (up to 8, then "and 3 more files"). The commit list shows up to 10 ("and 5 more commits").
On the current branch, it's the regular cherry-pick, from oldest to newest:
git cherry-pick a1b2c3d c3d4e5f
On another branch, without checkout, each commit is applied in memory on top of the branch tip and written as a new commit; at the end, the branch moves forward at once, checking that it didn't change along the way:
# for each commit, from oldest to newest:
git merge-tree --write-tree --merge-base=<commit-parent> <current-tip> <commit>
git commit-tree <resulting-tree> -p <current-tip> # same author, date and message
# at the end:
git update-ref -m "cherry-pick: 2 commit(s) (Versora)" refs/heads/release/1.4 <new-tip> <old-tip>
The working directory and the current branch don't change. The new commit keeps the original's
author, email, date and message; the committer is you. With commit.gpgSign on, the new commits are
signed too. Commits that wouldn't change anything are skipped.
Ctrl+Z undoes the whole cherry-pick ("Cherry-pick 2 commits onto release/1.4"): the branch goes back to the commit it was on before and, if there was a checkout, HEAD goes back to the previous branch. For a cherry-pick that stopped at a conflict (on the current branch, or with a checkout): while it's stopped, Abort on the bar puts everything back; if you resolve it and finish (Continue, or even from the terminal), it goes into Ctrl+Z as a whole, including the checkout that came before. If aborted, nothing goes into the history. See Undo and redo.
- "A merge can't be cherry-picked by dragging. Drag regular commits."
- "release/1.4 already contains these commits."
- "Too many commits at once. Use the interactive rebase.": the maximum is 100 commits in one drag.
- "Nothing to do: release/1.4 already has these changes.": all the commits would be empty.
- "Branch release/1.4 changed since the preview. Drag again to see the updated plan.": the branch moved between the plan and the click (a fetch, a commit in another worktree). Nothing was changed.
- "Cherry-picking a1b2c3d onto release/1.4 conflicts in 2 files. Nothing was changed.": the conflict showed up when applying; drag again and use Check out release/1.4 and cherry-pick.
- "Cherry-picking onto a branch without checking it out needs git 2.40 or newer. Check out the branch and try again." See Git version.
- "Conflict prediction needs git 2.40 or newer (this is …).": the window shows the plan without a prediction.
- "The tab changed: the plan was for another repository and was discarded. Drag again."
- Dropping onto a remote branch (or onto a remote's folder): the label says "→ can't commit to a remote branch" and nothing happens.
- There's no dragging with an operation in progress (merge, stopped rebase and so on), nor from the WIP row or a stash.
Preferences › Graph › Mouse › Drag commits ("Onto a branch label: cherry-pick. Onto another commit: rebase with a preview. Always with a confirmation and a conflict prediction."), on by default.
Dropping a commit onto another row of the graph changes its branch's base: the dragged commit and
all the ones that come after it on the branch go on top of the target commit. It's the --onto
rebase without typing any SHA: for example, taking feature/login (which started from an old
main) on top of today's main, by dragging its first commit onto the tip of main.
Drag the row of one commit in the graph and drop it onto another commit's row. While you drag, the graph shows the preview: the rows that would move are marked and the target row gets the label of the branch that would go there, with the count ("+3 commits"). The label next to the cursor says "Rebase feature/login onto e5f6a7b".
- Find the oldest commit that should change base, for example the first commit of
feature/login. - Drag it onto the tip of
mainand drop it. - The app builds the plan and opens the Rebase feature/login onto e5f6a7b window.
- If more than one local branch contains the commit, choose in Branch to move which one to take (for example "feature/login — current branch (3 commits)" or "feature/login-v2 (5 commits)"). The plan is redone right away.
- Read the plan and click Rebase (or Rebase anyway, with a conflict expected). If the plan shows commits that leave the branch (below), the button becomes Rebase and drop 2 commits, in red.
The dragged commit and the ones above it leave the "current base" (its parent) and go on top of the target. If you drop it onto an older commit of the same branch, the commits between the target and the current base stop being part of the branch. The plan doesn't hide this:
- a red block says "These 2 commits LEAVE feature/login: they sit below the dragged commit and the target doesn't have them, so the branch no longer contains them." (with one commit, "This commit LEAVES feature/login: …") and lists all of them, from newest to oldest, with the short SHA and the subject. The list stops at 300; beyond that, the last line says "and 12 more commits (the list stops at 300)";
- below the list, the block says whether those commits still exist somewhere:
- "All of them are still on other branches, tags or remotes." (with one commit, "It's still on another branch, tag or remote.");
- "1 of them isn't on any other branch, tag or remote: after the rebase, only Ctrl+Z (or the reflog) brings it back.";
- "None of them is on another branch, tag or remote: after the rebase, only Ctrl+Z (or the reflog) brings them back." (with one commit, "It isn't on any other branch, tag or remote: …");
- the confirm button becomes Rebase and drop 2 commits (with one commit, Rebase and drop 1 commit), in red, instead of Rebase.
The same block appears for any target that doesn't have some commit the branch had below the dragged commit (for example, a commit of another branch that started from an older point). To reorder or drop commits on purpose, the interactive rebase shows each one with its action.
| Part of the window | What it shows |
|---|---|
| Branch to move | The local branches that contain the commit, with how many commits each would take. The default is the current branch, if it contains the commit; otherwise, the one that takes the fewest commits. Only appears with more than one candidate. |
| Now / After preview | Now: the "current base" (the dragged commit's parent) and the commits that move. After: the target commit and the same commits, rebuilt (dashed outline). |
| Text | "3 commits of feature/login move on top of e5f6a7b (Atualiza dependências):" and the list. |
| Notes | "The app checks out feature/login for the rebase." (if it isn't the current one); "Stays where it is (points to a commit that will change): feature/login-ui." (other branches that point to commits that change); "1 of these commits is already on a remote: after the rebase, pushing feature/login will need a force push."; "You can undo it with Ctrl+Z." |
| Commits that leave the branch | Only when there are any: the red block with the full list (up to 300) and whether they're still on another branch, tag or remote. See the previous section. |
| Prediction | "No conflicts expected." or "Applying c3d4e5f (Valida o token) will conflict in 2 files:" and the files. |
| Button | Rebase; Rebase anyway, with a conflict expected; Rebase and drop N commits (in red), when there are commits that leave the branch. |
A single rebase, without autosquash and without taking other branches along (the user's
rebase.updateRefs setting doesn't apply here; the plan has already said who stays behind):
git -c rebase.updateRefs=false rebase --no-autosquash --onto e5f6a7b <dragged-commit-parent> feature/login
If feature/login isn't the current branch, git itself checks it out first. Before running, the app
checks that the branch tip is the same as in the plan. The conflict prediction is done in memory,
without touching the repository.
Ctrl+Z undoes the rebase ("Rebase feature/login"): the branch goes back to the commits it had before, including the ones the plan listed as leaving the branch, and HEAD goes back to the branch you were on.
If the rebase stopped at a conflict: while it's stopped, Abort on the bar undoes the whole rebase. If you resolve it and click Continue until the end (or finish it from the terminal), the rebase goes into Ctrl+Z as a whole, like one that didn't stop. If aborted, nothing goes into the undo history. See Undo and redo.
Caution
Dropping onto an older commit of the same branch removes the commits in between from the branch. The plan lists all of them in red and the button becomes Rebase and drop N commits: read the list before confirming. If you dropped them by mistake, Ctrl+Z brings the branch back.
- "There are uncommitted changes. Commit or stash them before the rebase.": the button disappears until the working directory is clean.
- "a1b2c3d is the repository's first commit: there's nothing to move."
- "a1b2c3d is a merge: drag a regular commit (or use the interactive rebase)."
- "No local branch contains a1b2c3d. To take the commit, drag it onto a branch label (cherry-pick)."
- "feature/login is already on top of e5f6a7b.": you dropped it onto its own parent.
- "e5f6a7b comes after a1b2c3d in feature/login: drop it on a commit that isn't it or above it."
- "There are merges between a1b2c3d and the tip of feature/login. Use the interactive rebase."
- "Too many commits to move by dragging. Use the interactive rebase.": the maximum is 300 commits.
- "Branch feature/login changed since the preview. Drag again to see the updated plan."
- Dragging several selected commits onto a row: "3 commits → to rebase, drag a single commit".
- While you drag, the preview only appears on valid targets: dropping onto the commit's own parent, onto a commit that would go along, onto the WIP row or a stash does nothing.
- The rebase rewrites the commits. If any was already on the remote, the next push needs to be forced: see Force push.
- If it stops at a conflict, see Stopped merge, rebase, cherry-pick and revert. The WIP row shows where the rebase stopped.
Preferences › Graph › Mouse › Drag commits (on by default). When it's off, the graph rows can't be dragged; dragging branches still works.
- Interactive rebase
- Predicting conflicts before an operation
- Stopped merge, rebase, cherry-pick and revert
| Where | What dragging does | See |
|---|---|---|
| Graph header | Reorders the columns. | The commit graph |
| Header dividers | Change the width of the columns. | The commit graph |
| Overview bar | Scrolls the graph. | The commit graph |
| Interactive rebase list | Reorders the plan's commits. | Interactive rebase |
| Tabs | Reorders the tabs. | Tabs |
| Home | Moves a project to a group. | Home and projects |
- Dragging branches: dragging a branch onto another one or onto a remote, in detail.
- Context menus: the same actions from the right-click menu.
- Undo and redo