Skip to content

Commit

Permalink
DOC: Add documentation for editing another persons PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai-Striega committed Mar 25, 2024
1 parent 50c0930 commit 43ce32a
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
49 changes: 49 additions & 0 deletions doc/source/dev/checking_out_an_upstream_pr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Editing another person's pull request

## Respect

Please be respectful of other's work.

## Expected setup

This guide expects that you have set up your git environment as is outlined in [getting_the_code](getting_the_code.md).
In particular, it assumes that you have:

1. a remote called ``origin`` for your fork of NumPy-Financial
2. a remote called ``upstream`` for the original fork of NumPy-Financial

You can check this by running:

```shell
git remote -v
```

Which should output lines similar to the below:

```
origin https://github.com/<your_username>/numpy-financial.git (fetch)
origin https://github.com/<your_username>/numpy-financial.git (push)
upstream https://github.com/numpy/numpy-financial.git (fetch)
upstream https://github.com/numpy/numpy-financial.git (push)
```

## Accessing the pull request

You will need to find the pull request ID from the pull request you are looking at. Then you can fetch the pull request and create a branch in the process by:

```shell
git fetch upstream pull/<ID>/head:<BRANCH_NAME>
```

Where:

* ``<ID>`` is the id that you found from the pull request
* ``<BRANCH_NAME>`` is the name that you would like to give to the branch once it is created.

Note that the branch name can be anything you want, however it has to be unique.

## Switching to the new branch

```shell
git switch <BRANCH_NAME>
```
49 changes: 49 additions & 0 deletions doc/source/dev/getting_the_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,55 @@ git clone https://github.com/<your_username>/numpy-financial.git

Hooray! You now have a working copy of NumPy-Financial.

## Adding the upstream repo

Now that your fork of NumPy-Financial is available locally, it is worth adding the upstream repository as a remote.

You can view the current remotes by running:

```shell
git remote -v
```

This should produce some output similar to:

```shell
origin https://github.com/<your_username>/numpy-financial.git (fetch)
origin https://github.com/<your_username>/numpy-financial.git (push)
```

Now tell git that there is a remote repository that we will call ``upstream`` pointing to the numpy-financial repository:

```shell
git remote add upstream https://github.com/numpy/numpy-financial.git
```

We can now check the remotes again:

```shell
git remote -v
```

which gives two additional lines as output:

```shell
origin https://github.com/<your_username>/numpy-financial.git (fetch)
origin https://github.com/<your_username>/numpy-financial.git (push)
upstream https://github.com/numpy/numpy-financial.git (fetch)
upstream https://github.com/numpy/numpy-financial.git (push)
```


## Pulling from upstream by default

We want to be able to get the changes from the upstream repo by default. This way you pull the most recent changes into your repo.

To set up your repository to read from the remote that we called `upstream`:

```shell
git config branch.main.remote upstream
git config branch.main.merge refs/heads/main
```

## Updating the code with other's changes

Expand Down

0 comments on commit 43ce32a

Please sign in to comment.