DEV Community

Cover image for Catching up a forked repo and contributing to open source
John Fay
John Fay

Posted on

Catching up a forked repo and contributing to open source

Story time

I've been learning about TypeScript and progressive web applications(PWA) a lot the past year. As I was creating and PWA I was trying to use auto completion and realized there were no types for an open source project I've grown fond of. I saw an opportunity to add some new utility to an open source project πŸŽ‰ This project is written in JavaScript and bundled using Babel. Converting a project from JavaScript to TypeScript can be difficult depending on how large the code base is .

To learn how to convert a project try reading Scripting from JavaScript to TypeScript.

Luckily for me this repository only had a few files and was a great opportunity to test my skills. I submitted my pull request(PR) and I was excited about it!

Open Source comment

Contributors started to give me positive feedback and things were progressing, but there were other priority requests in the maintainer's backlog. My contribution was overlooked for a bit, as expected. A rewrite from JavaScript to TypeScript can be a lot to review. Most of these people aren't getting paid to maintain a project. They do it as a courtesy and a way to give back to the community that has done it for them in the past. πŸ’ͺ

The other PR's were approved and merged into master and I realized there were many conflicts (After all it was a complete TypeScript rewrite). I wanted to resolve them quickly but ran into a new case I have yet to need to know until now. Someone else could learn from this so here's my quick take on it including some context.

Because that is what good people do

Reasons why we should contribute to open source projects

If you haven't contributed to any open source projects I would encourage you to do so. Even the simplest things such as a typo in documentation will change the way you consume as a JavaScript developer.

Avoid giving up on a project

I've heard many people complain about how a library isn't working for their use case so they give up on it. Some of these abandonments are warranted...many are not. It is often complaints that continue person to person until someone is courteous enough to report an issue to the maintainer.

Relieving some duties of the maintainer(s)

The next adventure is addressing and prioritizing the work so someone can start. You can imagine being a maintainer would be stressful if it all fell to you. By writing up the issue and contributing some code these maintainers should be ecstatic to see the community engaged in their work and wanting to improve on it.

Changing your outlook

I often run into people that don't grasp how the open source repositories get updated. For some reason it's easy to assume these are well funded organizations that will tackle every and all issues in a short time.

Haha good one

Getting into the code and contributing will show you how it all works! All the effort put in by everyone to build something useable is fascinating to me and I love the idea of helping to benefit more than yourself.

It's good for resume building and networking

I'm currently still in a work from home status and haven't been networking as much lately. By reaching out and offering your help you may make a new friend or gain a new connection that could lead to other opportunities.

My guess is that most developers aren't contributing to open source projects often, despite a common expectation in the job market.

If you do it's great for opportunities both in job searches and freelance connections.

How

Prerequisites

  1. You've already forked the repository.

  2. You've created a branch and PR to go into the original maintainer project.

  3. You have conflicts or an out of date forked repository.

  4. You're tired of reading leading in information and want to see what to do.

Configure git remote for the forked repository

For my example I'll be contributing to the react iOS PWA prompt. If you haven't seen it and enjoy the idea of PWA's check it out! iOS users don't have the generic google PWA prompt so this creates a react component to handle that case.

git remote add upstream https://github.com/chrisdancee/react-ios-pwa-prompt.git
Enter fullscreen mode Exit fullscreen mode

If you'd like to validate this worked you can run

git remote -v

// expected output
origin  git@github.com:keonik/react-ios-pwa-prompt.git (fetch)
origin  git@github.com:keonik/react-ios-pwa-prompt.git (push)
upstream    https://github.com/chrisdancee/react-ios-pwa-prompt.git (fetch)
upstream    https://github.com/chrisdancee/react-ios-pwa-prompt.git (push)
Enter fullscreen mode Exit fullscreen mode

Checkout master

git checkout master
Enter fullscreen mode Exit fullscreen mode

Merge upstream remote to master

git merge upstream/master
Enter fullscreen mode Exit fullscreen mode

Push it to your forked repo

git push
Enter fullscreen mode Exit fullscreen mode

Checkout your branch that is currently under review

git checkout {name-of-branch}
Enter fullscreen mode Exit fullscreen mode

Resolve the conflicts

Make sure you test and do all you can to catch the errors that could have been introduced by the new code. 🀞

Push that out

git push
Enter fullscreen mode Exit fullscreen mode

If you have to notify appropriate maintainers

I typically just tag the maintainers associated in the PR to let them know it's good to go.

Notification to maintainers

You're done! πŸŽ‰

Celebrate

I'm new to contributing to open source projects so I'd love to hear other benefits in the comments. Thank you for reading!

Top comments (0)