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.
Works in GitTree Free: every local Git feature, once you are signed in.
On this page
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.
| Action | macOS | Windows and Linux |
|---|---|---|
| Fetch All first | ⌘⇧F | Ctrl+Shift+F |
Steps
Fetch first
Fetch so GitTree knows where the remote branch is now; the lease is checked against what you last fetched.
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.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.