mirror of
https://github.com/jj-vcs/jj.git
synced 2025-12-23 06:01:01 +00:00
git: add --remote option to clone command
This makes it easier to work with multiple remotes at once while tracking the default branch of the remote used to create the local repository: ```shell $ jj git clone --remote upstream https://github.com/upstream-org/repo $ cd repo $ jj git remote add origin git@github.com:your-org/repo $ jj config set --repo git.fetch upstream ``` In the example above, `upstream` is the repository containing the reference source code that you might want to patch, while `origin` is your fork where pull-request will be pushed. The branch `main@upstream` will be tracked.
This commit is contained in:
parent
fc341855e5
commit
6e72b1cfb0
7 changed files with 65 additions and 7 deletions
|
|
@ -253,11 +253,22 @@ the [tutorial][tut].
|
|||
It is common to use several remotes when contributing to a shared repository.
|
||||
For example, "upstream" can designate the remote where the changes will be
|
||||
merged through a pull-request while "origin" is your private fork of the
|
||||
project. In this case, you might want to `jj git fetch` from "upstream" and to
|
||||
`jj git push` to "origin".
|
||||
project.
|
||||
|
||||
You can configure the default remotes to fetch from and push to in your
|
||||
configuration file (for example `.jj/repo/config.toml`):
|
||||
```shell
|
||||
$ jj git clone --remote upstream https://github.com/upstream-org/repo
|
||||
$ cd repo
|
||||
$ jj git remote add origin git@github.com:your-org/your-repo-fork
|
||||
```
|
||||
|
||||
This will automatically setup your repository to track the main
|
||||
bookmark from the upstream repository, typically `main@upstream`
|
||||
or `master@upstream`.
|
||||
|
||||
You might want to `jj git fetch` from "upstream" and to `jj git push`
|
||||
to "origin". You can configure the default remotes to fetch from and
|
||||
push to in your configuration file (for example,
|
||||
`.jj/repo/config.toml`):
|
||||
|
||||
```toml
|
||||
[git]
|
||||
|
|
@ -266,3 +277,13 @@ push = "origin"
|
|||
```
|
||||
|
||||
The default for both `git.fetch` and `git.push` is "origin".
|
||||
|
||||
If you usually work on a project from several computers, you may
|
||||
configure `jj` to fetch from both repositories by default, in order to
|
||||
keep your own bookmarks synchronized through your `origin` repository:
|
||||
|
||||
```toml
|
||||
[git]
|
||||
fetch = ["upstream", "origin"]
|
||||
push = "origin"
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue