Skip to content

Workspace Undo Push Commits

-- edited this page Nov 21, 2026 · 4 revisions

Open this from Repositories.

Undo Push Commits rolls back local commits that have not been pushed to origin yet. A branch that is on the remote resets to origin/<branch>. A branch that was never pushed (a new Feature branch, for example) has no such ref: it goes back to the commit where it left its base branch, which is the Feature's parent branch or otherwise the default branch. Remote history is unchanged, and nothing is pushed. Use this when you committed on the wrong branch (for example main), do not want those commits on origin, or cannot push because the default branch is protected.

Full protected-branch scenario (commit on main -> failed Push -> undo keep changes -> single-repo feature branch -> PR): Protected branch and push failure.

This walkthrough uses MezzoRecovery, a real multi-repo project. MezzoRecovery.Agent is on main with one outgoing commit: a dependency update that rewrote MezzoRecovery.Agent.csproj to pin MezzoRecovery.TapeDrive at tag 0.2.0.

When the menu item appears

Undo Push Commits is in the split menu of the yellow header button when any workspace repo has outgoing commits (or no upstream yet):

Header button Split menu also includes
Push Updated Level N Only, Update Only, Update Files, Push Only, Undo Push Commits
Push (yellow, no deps to update) Undo Push Commits

The same item appears on the Branch caret push section and on workspace notification cards (Push / Push Updated caret).

Pinned tags and repos with zero outgoing commits are skipped automatically.

Starting state - outgoing commit on Agent

MezzoRecovery.Agent shows:

  • Branch main
  • Divergence 0 | 1 (one commit ahead of default, nothing behind)
  • Commits badge yellow ↑1 ↓0
  • PR badge yellow create
  • Dependencies green 2 (the local commit aligned .csproj with current package versions)

Other Level 2 / 3 rows may already show red N of M deps badges (for example after a tag upgrade). Agent was fixed locally but not pushed.

Header is yellow Push Updated (unmatched deps elsewhere plus outgoing commits on Agent).

Agent with outgoing commit before undo

Open Push Updated and choose Undo Push Commits

Click the Push Updated caret. Undo Push Commits is the last item.

Push Updated menu with Undo Push Commits

Menu item What it does
Level N Only / Update Only / Update Files / Push Only Normal update and push workflow
Undo Push Commits Take the outgoing commits off every repo that has them (local only; nothing is pushed)

Primary Push Updated still runs update-then-push. Use the caret when you need to undo instead.

Confirmation dialog

The modal lists each affected repository and its outgoing commit count.

Undo Push Commits modal

  • The text says: all outgoing commits will be undone; a branch that is on the remote goes back to its origin branch, a branch that was never pushed goes back to where it left its base branch, and nothing is pushed.
  • Reset target: origin for the current branch (here origin/main). For a branch that was never pushed, the commit where it left its base branch. If no base branch can be found, the undo fails for that repository and changes nothing.
  • Keep changes (checked by default): mixed reset - commits removed, file edits stay in the working tree as unstaged changes. Use this to move the work onto a feature branch via Changes without losing edits.
  • Keep changes unchecked: hard reset - commits and edits are discarded. A red warning is shown.
  • Proceed runs resets in parallel under the loading overlay. Each repo sends a sync notification when done so commits badges update without a manual Sync.

Nothing in this flow contacts GitHub to push or delete remote commits.

After undo - outgoing commits gone

On MezzoRecovery.Agent after Proceed:

  • Commits badge green ↑0 ↓0 (matches origin/main)
  • Divergence 0 | 0
  • PR badge none
  • Version string drops back (GitVersion no longer includes the removed commit)

Agent after undo - no outgoing commits

Git on disk: main...origin/main with no unpushed commits. If Keep changes was left checked, MezzoRecovery.Agent.csproj may still show local edits until you commit on another branch or discard them.

Why dependencies turn red again

The undone commit changed PackageReference versions in .csproj. Removing it puts HEAD back to the pins on origin/main (for example MezzoRecovery.TapeDrive at 0.1.1-main.15) while MezzoRecovery.TapeDrive is published at tag 0.2.0 on Level 1.

GrayMoon compares committed .csproj pins to current workspace package versions. After a hard reset (or after discarding kept working-tree edits), Agent shows a red 1 of 2 badge again.

Agent red deps after undo

Fix paths (same as any unmatched-deps state):

  • Header Push Updated or Update Only on a feature branch (not protected main)
  • Click the red badge on one repo to update that repo only
  • See tag-upgrade.md - out-of-date dependencies for tooltip details (current -> expected)

Protected default branch

If main (or your default) is protected on GitHub:

  • Push / Push Updated will fail or be blocked even when the grid shows yellow ↑N.
  • Undo Push Commits is still available - it only runs git reset locally and never pushes.
  • Create a feature branch, cherry-pick or recommit your work, then push from there.

Related docs

Clone this wiki locally