DEV Community

Cover image for Open Source: My first Pull Request
MizuhoOkimoto
MizuhoOkimoto

Posted on

Open Source: My first Pull Request

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.

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😭)
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 on my fork repository.
image
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 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 anatoliyorigin. 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
Then, I went back to my main branch($git checkout main), and merged issue-5($git merge issue-5).
image
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_Storeand $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

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

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💥 It was great to collaborate with my partner and get support from my professor.
I still have some issues to improve my project, so I will update it soon 👍

Top comments (12)

Collapse
 
seokjeon profile image
Se-ok Jeon

Thx for this! This is really what I wanted. Helped A LOT.
Can I translate in Korean this post? If you don't mind, I wanna share this awesome post in Korean. Surely, There will be a link directing to this original post.

Collapse
 
okimotomizuho profile image
MizuhoOkimoto

Hello Se-ok! Thank you for saying so! I'm so happy if it would be helpful. I'm a still beginner at open-source and git, but I don't mind you sharing it 😍

Collapse
 
tugrul profile image
Tuğrul Topuz • Edited

You can choose merge on github then use git stash command and pull from remote repository then git stash pop is fluent then your approach. Consider you have 5 collegue and they pushed so many commits. Manual operation is a bit pain in this scenario

Collapse
 
okimotomizuho profile image
MizuhoOkimoto

Hi Tuğrul! Thank you for your comment and advice! I didn't know about git stash command 👀 Sounds tough if many people push many commits... I will try to use the command next time!

Collapse
 
tugrul profile image
Tuğrul Topuz

Hi Mizuho. You're welcome. Git is powerful and it has more tools in their toolbox. So interactive rebase is another good feature. You can edit entire history of commits but there is a vital point while making changes on. Commit history should not propagated your coworkers or you have to make plan and sync commit history all together with your coworkers

Thread Thread
 
okimotomizuho profile image
MizuhoOkimoto

Git is very interesting, but I'm still afraid of working on it with other people. I hope I can be a git manster😆 Thank you for the informative information!

Collapse
 
za profile image
Zach

Always cool to see new devs getting excited about open source! You should check out Hacktoberfest in a few days.

Collapse
 
okimotomizuho profile image
MizuhoOkimoto • Edited

Hi Zach! I was lost about what to do before but I'm pretty excited about open source now! My goal for the next four weeks is to sign up for the Hacktoberfest and actually make pull requests and get approved, so I'll post about it here again 😉

Collapse
 
thesanjeevsharma profile image
Sanjeev Sharma

Good going 👏

Collapse
 
okimotomizuho profile image
MizuhoOkimoto • Edited

Thank you, Sanjeev😊 I like your JavaScript tutorial blog!

Collapse
 
akacoder007 profile image
AkaCoder007

great

Collapse
 
okimotomizuho profile image
MizuhoOkimoto

Thank you so much😃