Skip to content
GitTree
Remotes and sync

Use a force push with lease

After you amend, rebase or reset commits you already pushed, a normal push is refused. Force Push (With Lease)… replaces the remote branch with yours, but only if it is still where you last fetched it, like git push --force-with-lease. GitTree never force-pushes any other way.

FreeUpdated

Works in GitTree Free: every local Git feature, once you are signed in.

On this page
  1. Before you start
  2. Where to find it
  3. Steps
  4. Expected result
  5. What the lease protects
  6. If something goes wrong
  7. Questions
  8. Related

Before you start

  • You rewrote commits that are already on the remote, and you know nobody else needs them as they were.

Where to find it

  • The command palette: Force Push (With Lease)….
  • Force Push… in the dialog that says the remote refused your branch.
ActionmacOSWindows and Linux
Fetch All first⌘⇧FCtrl+Shift+F

Steps

  1. Fetch first

    Fetch so GitTree knows where the remote branch is now; the lease is checked against what you last fetched.

  2. Read the confirmation

    Force push … to …? says which commits will be removed from the remote, and that the push only goes ahead while the remote is still at the commit you fetched. That tip is kept under refs/ogt/trash.

  3. Force push

    Press Force push …. Cancel is the default.

Expected result

The remote branch matches your rewritten branch; the commits it replaced are kept locally and can be restored.

What the lease protects

If someone pushed to the branch after your last fetch, GitTree says … moved and replaces nothing. Fetch to see what moved, bring it into your branch, then decide again.

If something goes wrong

“Fetch first: … has no fetched upstream to lease on”

GitTree needs to know where the remote branch is. Fetch, then force push again.

“Check out this branch to force push it.”

Force push works on the checked-out branch. Check it out first.

Questions

Can I undo a force push?

The remote is not changed by Undo; push again to change it back. The tip you replaced is kept under refs/ogt/trash, so you can restore it as a branch and push it.