Github: How to submit a pull request to an open source project (such as Deno)
Tags: github, opensource, pullrequest, tutorial
Published: 2021-05-09 09:00:30

<small>\* The cover image is originally by [Free-Photos](https://pixabay.com/users/free-photos-242387) and edited with great appreciation.</small>

---

## Intro

This post shows how I __submitted a pull request in [Github](https://www.github.com/)__ to an open source project such as, for example, [Deno project [denoland/deno]](https://github.com/denoland/deno) in order to __contribute to it__.

Well, [Deno](https://deno.land/) is a "secure runtime for [JavaScript](https://js.org/) and [TypeScript](https://www.typescriptlang.org/)" whose core developer is [Ryan Dahl](https://en.wikipedia.org/wiki/Ryan_Dahl), the original developer of the [Node.js](https://nodejs.org/). In more detail, Deno "uses [V8](https://v8.dev/) and is built in [Rust](https://www.rust-lang.org/)." (Yes, it is written in Rust lang.)

My modification this time had nothing to do with actual code of programming languages such as Rust, JavaScript and TypeScript or some shell scripts. It was on README.md, a basic markdown file, and just about English expression. We can get involved in contribution via even something like this.

## Tutorial

### To begin with

#### read contribution guide

Projects usually have the official contribution guides. Read them to follow their rules. [Here](https://deno.land/manual/contributing) is Deno's.

![contribution guide](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mzu7em4hjnu6erka12ni.png)

#### optionally, accept the requirements if necessary

Contributors are sometimes required to accept something. Deno requires "Contributor License Agreement" via [CLA assistant](cla-assistant.io).

![cla assignment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k7xp17zu5um2cnbx0qhh.png)

### Steps

#### 1. fork

Fork a copy of the repository in a web browser. Just click "Fork".

![github fork](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rv4as1j88zmhxw0fhkfn.png)

#### 2. git clone

Now you have a copy of the repo as yours.

![github clone](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dgs0arbolzbt6bv4eitx.png)

Get it.

```console
$ git clone <your/repository>
```

![git clone](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zoxlctsfysex04e449g1.png)

#### 3. create a branch to edit

Create a branch which contains only your changes and is bound to a pull request later. 
The branch name should be unique and easy to understand what it is for. If there is an open issue related, the branch name may include its ID.

```console
$ git checkout -b <branch-name>
```

![git checkout branch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ieahegjwrk32ja35vt6u.png)

#### 4. modify and test

Edit files as needed with editors or IDEs.

![edit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ab07y6q6lhbbvn5ra8uq.png)

Run tests.

#### 5. check diff

Confirm there are only changes which you are intended to make.

![git diff](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7pc6x2eirxgj8oz2i66z.png)

#### 6. commit

Commit the changesets.

```console
$ git add .
$ git commit -m "<comments should be short and describe summary>"
```

![git add and git commit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ivmrrjtnn2v3khweemdm.png)

#### 7. push to own repository

```console
$ git push origin <branch-name>
```

![git push](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rv46r0t81xzjis7twrwa.png)

#### 8. open a pull request and submit it

Open the own repository in a web browser and choose the pushed branch. You will see the green button "Open pull request". Click it.

![open a pull request in a web browser](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qodidheof2ktcowe5l7y.png)

Here is the final stage to submit the pull request to the original project. Read the comments, which are provided by the project, carefully, write your description and review the validity by yourself. Check "Files changed" again. Then publish it.

![submitting the pull request](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m5q60tpgvw3agmeuif8l.png)

#### 9. wait to be reviewed

Done. It will be reviewed by the project. Wait with patience.

![done](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g5up6afg9rsjv6x4ym7i.png)

## Outro

After the submission above, my reviewer replied to me and I followed his advice. I did `git commit` and `git push origin <branch-name>` again. Then I opened my Github repo page in a web browser and clicked "Fetch upstrean" -> "Fetch merge" to reflect the new commit in the pull request. It was accepted by the reviewer.
After all, my pull request passed all the checks and has been "merged" to the "main" branch in the project 🙂