Github: How to submit a pull request to an open source project (such as Deno)

nabbisen - May 9 '21 - - Dev Community

* The cover image is originally by Free-Photos and edited with great appreciation.


Intro

This post shows how I submitted a pull request in Github to an open source project such as, for example, Deno project [denoland/deno] in order to contribute to it.

Well, Deno is a "secure runtime for JavaScript and TypeScript" whose core developer is Ryan Dahl, the original developer of the Node.js. In more detail, Deno "uses V8 and is built in Rust." (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 is Deno's.

contribution guide

optionally, accept the requirements if necessary

Contributors are sometimes required to accept something. Deno requires "Contributor License Agreement" via CLA assistant.

cla assignment

Steps

1. fork

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

github fork

2. git clone

Now you have a copy of the repo as yours.

github clone

Get it.

$ git clone <your/repository>
Enter fullscreen mode Exit fullscreen mode

git clone

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.

$ git checkout -b <branch-name>
Enter fullscreen mode Exit fullscreen mode

git checkout branch

4. modify and test

Edit files as needed with editors or IDEs.

edit

Run tests.

5. check diff

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

git diff

6. commit

Commit the changesets.

$ git add .
$ git commit -m "<comments should be short and describe summary>"
Enter fullscreen mode Exit fullscreen mode

git add and git commit

7. push to own repository

$ git push origin <branch-name>
Enter fullscreen mode Exit fullscreen mode

git push

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

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

9. wait to be reviewed

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

done

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 🙂

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .