2017-11-23 20:21:57 +01:00
|
|
|
# Collaborate
|
|
|
|
|
|
|
|
## Fetch another contributor's branch
|
|
|
|
|
|
|
|
What happens when you would like to collaborate with another contributor and
|
|
|
|
they have work-in-progress on their own fork of Zulip? No problem! Just add
|
|
|
|
their fork as a remote and pull their changes.
|
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```console
|
2017-11-23 20:21:57 +01:00
|
|
|
$ git remote add <username> https://github.com/<username>/zulip.git
|
|
|
|
$ git fetch <username>
|
|
|
|
```
|
|
|
|
|
2020-10-13 23:50:18 +02:00
|
|
|
Now you can check out their branch just like you would any other. You can name
|
2017-11-23 20:21:57 +01:00
|
|
|
the branch anything you want, but using both the username and branch name will
|
|
|
|
help you keep things organized.
|
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```console
|
2017-11-23 20:21:57 +01:00
|
|
|
$ git checkout -b <username>/<branchname>
|
|
|
|
```
|
|
|
|
|
|
|
|
You can choose to rename the branch if you prefer:
|
2021-08-20 22:54:08 +02:00
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
2017-11-23 20:21:57 +01:00
|
|
|
git checkout -b <custombranchname> <username>/<branchname>
|
|
|
|
```
|
|
|
|
|
2020-10-13 23:50:18 +02:00
|
|
|
## Check out a pull request locally
|
2017-11-23 20:21:57 +01:00
|
|
|
|
2020-10-13 23:50:18 +02:00
|
|
|
Just as you can check out any user's branch locally, you can also check out any
|
2017-11-23 20:21:57 +01:00
|
|
|
pull request locally. GitHub provides a special syntax
|
|
|
|
([details][github-help-co-pr-locally]) for this since pull requests are
|
|
|
|
specific to GitHub rather than Git.
|
|
|
|
|
2021-08-20 22:54:08 +02:00
|
|
|
First, fetch and create a branch for the pull request, replacing _ID_ and
|
|
|
|
_BRANCHNAME_ with the ID of the pull request and your desired branch name:
|
2017-11-23 20:21:57 +01:00
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```console
|
2017-11-23 20:21:57 +01:00
|
|
|
$ git fetch upstream pull/ID/head:BRANCHNAME
|
|
|
|
```
|
|
|
|
|
|
|
|
Now switch to the branch:
|
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```console
|
2017-11-23 20:21:57 +01:00
|
|
|
$ git checkout BRANCHNAME
|
|
|
|
```
|
|
|
|
|
|
|
|
Now you work on this branch as you would any other.
|
|
|
|
|
|
|
|
Note: you can use the scripts provided in the tools/ directory to fetch pull
|
2021-08-20 22:54:08 +02:00
|
|
|
requests. You can read more about what they do [here][tools-pr].
|
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
2017-11-23 20:21:57 +01:00
|
|
|
tools/fetch-rebase-pull-request <PR-number>
|
|
|
|
tools/fetch-pull-request <PR-number>
|
|
|
|
```
|
|
|
|
|
2019-02-26 02:49:09 +01:00
|
|
|
[github-help-co-pr-locally]: https://help.github.com/en/articles/checking-out-pull-requests-locally
|
2021-08-20 22:54:08 +02:00
|
|
|
[tools-pr]: ../git/zulip-tools.html#fetch-a-pull-request-and-rebase
|