How to Contribute to Open Source Project - Your First GitHub PR
Tags: github, opensource, bytebase
Published: 2022-04-26 02:49:00

If you are **a tech beginner / non-tech person** and wonder **how to contribute to an open-source project**, this is THE article for you. I'll take [Bytebase](https://bytebase.com/)'s open-sourced documentation as an example to guide you through the whole process.

Bytebase is an open-source database tool for DBAs and developers; it's the GitLab for database schema lifecycle management. It open-sourced its [official documentation](https://bytebase.com/docs/what-is-bytebase) since v1.0.2.

Let's get started; make sure you install [Git](https://git-scm.com/) and have a [GitHub](https://github.com/) account. If you have any questions about git, ask google or https://git-scm.com/docs.

## Preparation 
- Visit https://github.com/bytebase/bytebase.com; as we can see, actually Bytebase open-sourced the whole website, but we only pay attention to docs/.
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649847707759/dNCEoCm9Z.png)

- Under your project folder, do git clone to download the whole repository.
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649847742511/460nbB8rJ.png)

- Yes, now we have the code, and here is the most popular editor code.visualstudio.com

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649847762249/va9NbTLDO.png)


- Open the folder from VSCode

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649847775891/sfLhJbujr.png)

## Delete a file
### Do the Delete
- Our first example is to remove a page - Bytebase sunset a feature in [v1.0.0](https://bytebase.com/changelog/bytebase-1-0-0), but the related file is still there. 
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649847896059/OYsXDa-Yp.png)

- Within the editor, it's super straightforward - delete this file.
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649847903334/oNXgStlkd.png)

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649847917947/106foyoLd.png)

### Commit and Push
- After deletion, we use Terminal to view the current status - the file is deleted, yes, that's right! 

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649847931710/FppItwKnY.png)

- Git commit with the message telling what this commit is for.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649847940435/5RmuQ8DvB.png)

- The changes are committed, and that's not enough; we need to synchronize it to the remote branch so that others can see. And ... We encountered this!

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649847960575/hth6HAVYi.png)

- It's because we are now in the main branch. If we build our own code repository, it's OK to push directly to the main branch. But now we are trying to make changes to others' project. Let's get to the document guidance here. 
https://bytebase.com/docs/document-write-guide

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649847984577/OMNIrn-Bo.png)

### Create a PR
- "Create a new PR" - how? First, we need to create a new branch to push our local copy to remote. If you are similar to me - not so familiar with the git command, google is always there for you.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848000479/1NALEBQOk.png)

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848007712/vR7EXFiWV.png)

- We use the command  "git checkout -b xxx" to create our branch

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848018870/wu0_00cpe.png)

- Then push to remote

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848025925/zbYdcid0J.png)

- Set the upstream and push to remote  "git push --set-upstream origin remove-sql-rollback-page".

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848036725/nJbzgcwOZ.png)

- Let's get back to GitHub; click the "Pull requests" tab

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848045744/OCRt4-mYmz.png)

- We can see the push, but let's click "New pull request"

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848054614/h5cN_dZni.png)

- Here we can see our branch, click!

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848061907/12l4eWVSX.png)

Here, you can make the comparison, but it's pure deletion for our case. Click "Create pull request"!

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848070876/Q7gplz2xm.png)

- Succeed!

## Update a file
### Do the Update
- Our second case is to update. When we copy images from google docs, it will have its self-generated link. What we need to do is to replace that with static/doc-assets/xxxx.png from the same repository.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848089406/3dJwDpfZz.png)

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848098300/hTT-r52rA.png)


- Firstly, I download all the related images and move these to static/docs-assets/

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848107447/2Qw2b-ODl.png)

- The file names should be prefixed to stay together
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848116870/7GZm0xNPJ.png)


- Then update the corresponding file. I keep the old files there to ensure the new images look the same.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848129269/OMf1_wwZV.png)

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848144596/PjLLFaNda.png)

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848152098/ydCD7YjUy.png)


- Do git status to view the status.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848167084/l9FukE4p9.png)

### Preview Locally
- This time, we want to preview locally before committing. On https://github.com/bytebase/bytebase.com, you can find development instructions at the end of README.md

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848179453/XhkY-5OW0.png)

- We run "pnpm i & pnpm dev" and it compiles successfully. Now we can visit http://localhost:3000 and preview the whole site.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848186778/mJGgjY2Aq.png)

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848301235/zlaGwmvkq.png)

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848312952/TSPH8muCS.png)

### New PR
- Everything seems fine to me, now let's create another branch and then a new PR

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848324240/NiR-KnhmB.png)

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848332608/Wdin8UB0F.png)

- The link is here:
[Update img link tenant database management by adela-bytebase · Pull Request #82 · bytebase/bytebase.](https://github.com/bytebase/bytebase.com/pull/82)
### The Preview
- How handy this is!!! Bytebase integrates a render bot to generate a PR preview, which means others can follow this link to preview my PR. No need to download and run locally!

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848376638/ihjVlMBuZ.png)

### Change Requests
- Then, I got my first "change request".

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848392432/kMKzN93xu.png)

- Then, the second.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848401331/c3pYlORUT.png)

- Yes! I forgot to push all the images ... And another commit and push.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848410620/JDsucCEsi.png)

- Remove the letters "dddd".

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848426540/6CverUgnZ.png)

- Then, I need to re-request reviews from them again.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848438540/H1zBxwHVQ.png)

### LGTM and Merge
- If you look at this https://github.com/bytebase/bytebase.com/pull/82, you'll find that I have other mistakes. Thanks to my super careful reviewers!!! At last, I see "LGTM"!

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848451772/UBcx5EEmt.png)

- And I can merge!!!!

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649848458564/bB77zGlus.png)