Skip to content

fix: push where git push would, and skip branches it has no destination for - #19

Merged
pablospe merged 1 commit into
mainfrom
fix/push-destination
Nov 15, 2026
Merged

pablospe merged 1 commit into
mainfrom
fix/push-destination

Conversation

@pablospe

Copy link
Copy Markdown
Owner

In diffnav, clipboard-error was started from upstream/main, the original author's repo, and tracks it. wt sync -p took the branch's remote and ran git push --force-with-lease upstream clipboard-error, a force-push to someone else's repo. GitHub refused it this time (exit 128), but if you had write access there it would have gone through. Plain git push refuses it: with push.default=simple and an upstream named differently, git has no single destination.

Pushes now go where git's own @{push} says, read for all branches with one for-each-ref (%(push) and %(push:remotename)). %(push) still resolves when the remote branch was deleted, so the case where the remote branch is gone keeps pushing as before. A branch that has an upstream but no push destination is skipped with a hint, in the real run and in the dry-run plan:

Not pushing clipboard-error: it tracks upstream/main, so git has no single place to push it. Push it once with `git push -u <remote> clipboard-error` to choose one.

The same goes for a branch tracking origin/main under another name, which used to get a new branch created on origin. With push.default=upstream the push now uses a branch:remote-branch refspec, matching what git does. Branches without an upstream are still skipped silently.

New tests/push.rs with local bare remotes: a branch tracking upstream/main is not pushed there while the normal one is, and a branch whose remote branch was deleted is still pushed.

@pablospe
pablospe merged commit 68ef550 into main Nov 15, 2026
2 checks passed
@pablospe
pablospe deleted the fix/push-destination branch November 15, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant