jj
jj copied to clipboard
FR: Push local branch to a remote branch with a different name
Is your feature request related to a problem? Please describe. I am trying to deal with multiple remotes that have unrelated branches with the same name. I can make local branches the remote ones that have different names just fine, but there does not seem to be a way to push those branches without creating new ones on the remote.
Describe the solution you'd like
jj branch track --local my-local-name branch@remote
This assumes #1278 is resolved
Describe alternatives you've considered
jj git push --branch my-local-name --remote-branch branch@remote
# or
jj git push --branch my-local-name --remote branch@name
Related: #2098 (for the alternatives)
I'm not sure if jj should support tracking local branches of different names because of UI complexity.
I keep needing this during code reviews when needing to handle different sets of changes on master@origin
and master@someremote
. I couldn't figure it out in jj and ended up just dropping into git to handle the branch names explicitly. Is there a simpler way in the short term?
@dbarnett If you're not trying to push to both master@origin
and master@someremote
(ie you're only trying to push to master@origin
) you can set your master
to track just one of them (master@origin
) and refer to the other with its @remote
(master@someremote
). You don't have to have a local branch tracking the remote branch in order to reference the commits on the remote branch.
You can also make a local branch that is at the same position (but does not automatically track) the remote branch using a different name. This could be useful if you want to have both of the master
branches on one remote, but one with a different name (ie jj branch c someremote/master -r master@someremote && jj git push someremote/master --remote origin
). The only problem thing you can't do here that is highlighted in this issue is easily push changes from your branch that has a different name to the master
branch on the remote that it was derived from.