-
Notifications
You must be signed in to change notification settings - Fork 397
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
FR: Different git URLs for fetch and push #5611
Comments
I think this is achievable today with https://jj-vcs.github.io/jj/latest/config/#default-remotes-for-jj-git-fetch-and-jj-git-push, but I'm not sure. |
Ahh yes that does indeed work. I've update the OP of this issue to mention it as another workaround. I'd still like to leave this issue opened, though, since this workaround is still slightly sub-optimal IMO. Here is the paragraph I added to the OP: Another workaround suggested in #5611 (comment) is to use an alternate remote for pushing. This also works just fine. The only drawback is that it forces me to come up with a name for the 2nd remote ("origin_ssh" in this case), and that is a notoriously hard problem in computer science (source). Here's what it looks like though. It's exactly the same as the bash shell snippet above, except that the raw
|
I think this FR can be summarized as: Add support for
I think the simplest solution for you until this is implemented, is to use the above mechanism and a |
Is your feature request related to a problem? Please describe.
I regularly use different URLs for fetching from and pushing to my git repositories. Specfically, I like to use the https URL for fetching and the ssh url for pushing. With this setup I can fetch from the remote even in a shell where ssh-agent is not set up (since fetching https urls for public github repos does not require authentication). But then when I want to push I must use the ssh url since the repos that I frequently use require pushes to be authenticated via ssh keys. Therefore, the extra burden of setting up ssh-agent is only needed when I actually want to push; simply fetching does not require ssh-agent setup.
For example, when using git, here is how I would clone a repo and configure the easier-to-use https url for fetching, but the more-difficult-to-use-but-required ssh url for pushing:
With this setup, running
git fetch
works just fine, even thoughssh-agent
isn't running, because it's using the https url, which doesn't require authentication:But running
git push
requests the ssh key's passphrase, as expected, because it's using the ssh url, which is required by the repo for pushes:This means I only have to set up ssh-agent or enter my ssh key passphrase when it's strictly required; that is, when pushing to the repo.
Describe the solution you'd like
I'd like to see the jj command
jj git remote set-url
gain a--push
flag to do the same thing asgit remote set-url --push
.For example, I'd like to be able to run something like this (notice the
--push
flag, which I am proposing):Additionally, the
jj git remote list
output should include both the push and the fetch URLs, especially if they are different. As of the latest version (0.26.0 at the time of writing) the output only includes the fetch URL, even if it is different from the push URL (see the workaround in next section an example of how the URLs can be different).Describe alternatives you've considered
The workaround that I use is to run
git
directly on the git repo in the.jj
directory to set the push url. This requires that I figure out or memorize the path to the git repo in the.jj
directory. It works just fine, but it would be nice to just have this support built into the jj cli so I don't have to grok the.jj
directory.For example, here is how I use
jj
to work on thefirebase-js-sdk
github repository used above:Note how
jj git fetch
succeeded. This is because fetch used the https url, which does not require any sort of authentication. Also note how thejj git push
command initially failed (as expected) because it used the ssh url. After runningssh-add
the push command succeeded (as expected). This is the workflow that I like because it makes it easy to fetch and I only have to set up ssh-agent when I actually want to push something up to the remote repository.Another workaround suggested in #5611 (comment) is to use an alternate remote for pushing. This also works just fine. The only drawback is that it forces me to come up with a name for the 2nd remote ("origin_ssh" in this case), and that is a notoriously hard problem in computer science (source).
Here's what it looks like though. It's exactly the same as the bash shell snippet above, except that the raw
git --git-dir=...
commands above are replaced by:Additional context
Since there is a workaround (i.e. running
git --git-dir .jj/repo/store/git remote set-url origin --push <url>
) this isn't super-high priority or blocking or anything. But for me it's a nice-to-have.The text was updated successfully, but these errors were encountered: