Catching up a forked repo and contributing to open source
Tags: opensource, git, github, typescript
Published: 2020-11-05 01:57:04

## Story time

I've been learning about [TypeScript](https://www.typescriptlang.org/) and [progressive web applications(PWA)](https://web.dev/progressive-web-apps/) 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](https://babeljs.io/). 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](https://dev.to/keonik/scripting-from-javascript-to-typescript-lh3).

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](https://dev-to-uploads.s3.amazonaws.com/i/5rudwc56tyhke52ib6ea.png)

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](https://media3.giphy.com/media/gg9LCtsjjBninkG52i/giphy-downsized.gif?cid=6104955e88c4cd9d467590ce06a7cfa4f49ee86153b09ae0&rid=giphy-downsized.gif)

## 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](https://media4.giphy.com/media/4T3r8IKOkGDcLKBJ6y/giphy.gif?cid=6104955ed6909916cd9742d6474f68fe5e060573dc74dabb&rid=giphy.gif)

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.

{% twitter 1313303791186268160 %}

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](https://github.com/chrisdancee/react-ios-pwa-prompt/pull/49). If you haven't seen it and enjoy the idea of [PWA's](https://web.dev/progressive-web-apps/) check it out! iOS users don't have the generic google PWA prompt so this creates a react component to handle that case.

```bash
git remote add upstream https://github.com/chrisdancee/react-ios-pwa-prompt.git
```

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

```bash
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)
```

### Checkout master

```bash
git checkout master
```

### Merge upstream remote to master

```bash
git merge upstream/master
```

### Push it to your forked repo

```bash
git push
```

### Checkout your branch that is currently under review

```bash
git checkout {name-of-branch}
```

### 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

```bash
git push
```

### 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](https://dev-to-uploads.s3.amazonaws.com/i/d68swwz9d4h0kx2qhpxc.png)

## You're done! 🎉

![Celebrate](https://media1.giphy.com/media/6nuiJjOOQBBn2/giphy.gif?cid=6104955e84eaf10d9a63254d453351fcdc4cbbec18a5fa39&rid=giphy.gif)

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