Open Source: My first Pull Request
Tags: opensource, github, webdev
Published: 2021-09-25 03:38:53

After I published an open source project which creates a static site generator(SSG), my second lab assignment was adding new features and making a Pull Request with my partner's same project. My partner, Anatoliy, also created a SSG in JavaScript and his way to convert text file(s) to HTML file(s) was organized and clear.
- Anatoliy's Project on GitHub: https://github.com/aserputov/qck-ssg-final
- My Project on GitHub: https://github.com/MizuhoOkimoto/pajama-ssg

## New features
There are 2 required features.
1. Modify the file handling so that it supports both .txt files as well as .md, and parse one aspect of Markdown into HTML.
2. Implement one of the Markdown syntax features for Italics, Bold, Heading1.

First of all, I used Fork on his GitHub repository, and cloned to my GitHub repository. Then, I cloned it to my local computer, and created a new branch for my work with this command `git checkout -b issue-5`.

## Initial Thoughts
Last week, when I tested and reviewed his project, I thought I understood his way and the code structure. However, when I started trying to implement the new features, I hit a wall. I had to ask him to explain his way and he sent me some videos to explain!(It was at 2am! Thank you, my sweet friend:sob:)
I communicated with him and I finally implemented the new features by adding some functions for reading .md file, and used replace methods to replace to markdown. Unfortunately, I had another problem. I installed Prettier on my local machine globally, so when I type `**` to make the line bold, it became `-`or `\*`, so I couldn't test the implementations.

## Making a Pull Request
After I finished the implementations, I made a [pull request](https://github.com/aserputov/qck-ssg-final/pull/6) on my fork repository.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m96p61i3m7zd9snejacy.png) 
On my terminal, I changed the branch to issue-5, added the JavaScript file and updated README.md, committed, and pushed to the issue-5.
I posted a comment what I implemented with a sample on GitHub, and asked him to review and merge it.

## Receiving a Pull Request
I received a [pull request](https://github.com/MizuhoOkimoto/pajama-ssg/pull/15) from Anatoliy, and I found a problem. After he Fork my repository, I updated my project, so there were some conflicts. I was afraid I would lose my updates when I merged his code, so I asked my professor and he worked me through how to merge.
 
## How I merged and rebased
First, I cloned my project's repository on my local computer, and checked with `git status`. It showed `Your branch is up to date with 'origin/main'`. Then, viewing git remote configurations(`$git remote`), and added Anatoliy's repository and named it `anatoliy`(`$git remote add anatoliy https://github.com/aserputov/pajama-ssg.git`). After I added his repository, I checked remote configuration again, it showed `anatoliy``origin`. So I downloaded the commits, files, and refs from a remote repository into my local repo(`$git fetch anatoliy`), and checked the past commits.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/as52b3a7gped8sne5dvm.png)
Then, I went back to my main branch(`$git checkout main`), and merged issue-5(`$git merge issue-5`).
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gsstxli1a5zhxoqkr3gt.png)
I had some unmerged files, so I opened a pull request and filed changes on GitHub, so I could check what I should or shouldn't merge. For Example: `$ git rm .\.DS_Store`and `$git add README.md`
After I committed it (`$git commit` without message), I checked with `$git log`, and I could see that I finally merged everything.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/doysvrj8cfde8dbga0kf.png)

## Closing a Pull Request
My professor taught me how to send a request change based on the pull request. First, inside the pull request page, I clicked the "View changes" button, checked the changes, then made a Review changes and submitted. 
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4qwdkoc6gaswa0t1auhy.png)

Conclusion:
I didn't like Git before, because it's complicated and I always get a bunch of error messages. However, after I watched my professor's lectures and through this assignment, I'm getting to like it. I feel like Git is magic:boom: It was great to collaborate with my partner and get support from my professor.
I still have some [issues](https://github.com/MizuhoOkimoto/pajama-ssg/issues) to improve my project, so I will update it soon :thumbsup: