Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jj tries to push branch to @origin even though it's tracking @priv #3050

Closed
colemickens opened this issue Feb 14, 2024 · 3 comments
Closed

Comments

@colemickens
Copy link
Contributor

Description

jj git push seems to pick the wrong remote to push to for tracked branches. This is quite scary, luckily the one time I accidentally pushed without specifying remote, I was blocked from pushing to a different, protected branch on origin, which prevented the private feature branch from getting pushed publicly.

I have a repo with two remote repos project and project-priv, added as origin and priv origins.

> jj branch list
colemickens/foo-spike: onlxxxuu deadb33f (empty) test commit
  @priv (behind by 1 commits): swyyyvst deadbeef foo
...

but...

>  jj git push --dry-run
Branch changes to push to origin:
  Add branch colemickens/foo-spike to deadbeef
Dry-run requested, not pushing.

I can't tell if this is a feature request or a bug.

@ilyagr
Copy link
Contributor

ilyagr commented Feb 14, 2024

This seems expected to me, so I think this is a feature request (but sorry about your scare!). We should probably try to improve this.

jj git push always pushes to the default remote (origin, unless you change it in the config) if you don't specify one. Since a local branch can track more than one remote, I'm not sure whether it could push to "the" tracked branch by default.

Some possibilities that come to mind:

  • You could name your private remote "origin", and name the public one "public" or "upstream", or you could change the default remote.
  • We should probably have a way to forbid pushing a branch to the remote even if the branch doesn't yet exist there (or if jj doesn't know about it yet). If branch@origin did exist, we already have a way: jj branch untrack branch@origin would prevent push from ever pushing to that remote.
  • In principle, we could have a "safe mode" where jj git push refuses to create branches unless you pass a flag to it. It would probably apply to branch deletion too.

@yuja
Copy link
Contributor

yuja commented Feb 15, 2024

Perhaps, this is dupe of #1278. iirc, Git has a concept that a local branch is associated with one tracked remote to push.

@yuja
Copy link
Contributor

yuja commented Mar 7, 2024

(closed as duplicates)

@yuja yuja closed this as completed Mar 7, 2024
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

No branches or pull requests

3 participants