martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
8.07k stars 264 forks source link

FR: Git `push-to-branch` #3588

Open Cretezy opened 4 months ago

Cretezy commented 4 months ago

Is your feature request related to a problem? Please describe.

When pushing to a git remote, 2 operations must happen:

  1. jj branch set <branches> -r <revision> (and optionally create until https://github.com/martinvonz/jj/issues/3584 lands)
  2. jj git push

Describe the solution you'd like

git push-to-branch <branches> -r <revision> which would push branches to the remote.

This would behave similarly to jj branch set (possibly with --allow-backwards) and jj git push (although would only push the related branches/revision).

Potential options:

How it would look

# Start new change
jj fetch
jj new main@origin
# Do changes, commit
jj commit
# Push it up!
jj git push-to-branch my-cool-change -r @-
# Make more changes. Can either be a new commit after, or squashed into previous commit
jj commit / jj squash
# Update the remote branch with our changes (however they were recorded)
jj git push-to-branch my-cool-change -r @-

Open questions

  1. Should this command create local branches or remote-only?
khionu commented 4 months ago

I'm not a fan of this. Doing VCS operations and pushing them at the same time feels like a large footgun. With branch auto advancing, the "commit, branch set, push" flow is already getting reduced from 3 to 2 steps.

yuja commented 4 months ago

https://github.com/martinvonz/jj/pull/2098#issuecomment-1682522251 might be related. It adds a command to push commits to the specified remote ref (without creating a local ref.)