DEV Community

Cover image for Getting started with your first open source project
Osahenru
Osahenru

Posted on

Getting started with your first open source project

Prerequisite

I expect the reader of this article to have an existing GitHub account and is fairly familiar with GitHub and a few command like git status, git commit, git add .

However if you're not familiar with GitHub checkout this beginners guide

What is open source

I can relate to how the term ‘open source’ sounds like a term used only by those who are perceived as the top dog by other developers well, I fairly understand, open source just merely means project which are open for contributions and this is intentionally done by the creators of these projects.

As a contributor you can contribute to an existing issue or create one yourself (although as a beginner I recommend you stick with the former of contributing to an existing issue), for the purpose of this article an issue can be said to be a list of improvements required for the project to function optimally either as fixing a bug or requesting additional functions to the project

A good issue is one which has a tag, has a simple title, has been opened for at least a year (as a beginner you don’t want to contribute to an issue that has been left unattended to with zero to few interactions).

So, now, you have spotted an issue you feel comfortable contributing to, you need to notify the maintainer of that project by sending a comment to assign the issue to you.

Please give time before you get feedback from the maintainer as most times the feedback might not be instance as most have other project they are maintaining or have a busy work life.

If you’re not sure of where to find open source project easily, sign up to hacktoberfest and browse through their list of sites where you can find good open source projects, alternatively below are some sites you can easily check out too
Ups for grabs
Good first issues
Good first issues dotdev

While you’re waiting for a response from the maintainer you can familiarize yourself with the project's code base for this sole reason is why I strongly encourage beginners to contribute to open source projects because you’ll be exposed to the code base of the project where you can familiarize yourself on the industry way of writing clean and maintainable codes and the exposure to collaboration too is very rewarding when you’re in search of a job.

Forking a project

Once an issue has been assigned to you, next, you need to FORK the repository of that project to your GitHub repository

To fork a repo according to Thanoshan MV means

When we love someone’s repository and would like to have it in our GitHub account, we fork it so that we can work with it separately. When we fork a repository, we get an instance of that entire repository with its whole history. After forking, we can do whatever we want to do without affecting the original version

unrelated but I find this definition really hilarious more so that the pronunciation of the word has other meanings, makes me wonder what the engineers at GitHub were thinking about while coming up with their naming conventions… 😂😂😂

You might fork a project to propose changes to the
upstream(original repository).

Image description

Select an owner(which in most case is you) scroll down and CLICK create fork

Cloning a forked repo

So you have successfully forked the project you want to work on but you need to clone it to make it available on your local machine so you can work on it, to do this navigate to your newly forked project which usually has this naming convention [YourName/Name-of-forked-project]

Above the list of files CLICK code copy the URL using HTTPS

Now to clone this project to your machine open your terminal, change directory to where you want your project cloned and type git clone followed by the URL you just copied and press ENTER

Syncing your forked project with the original repo

In an open source project you’ll always have different contributors working on different issues so to keep with the latest commit or changes we need to sync our forked project with the upstream.

On your GitHub account navigate to the repo of the original project where you forked from.

Above the list of files CLICK codejust close to the Add file icon, copy the URL using HTTPS.

cd into the directory of the earlier forked clone type git remote -v press ENTER to see the remote name of the repo you just forked.

your output should look something like this

origin  https://github.com/YourName/OriginalNameofYourFork.git (fetch)
origin  https://github.com/YourName/OriginalNameofYourFork.git (push)
Enter fullscreen mode Exit fullscreen mode

Type git remote add upstream and then paste the URL you last copied followed by ENTER

your command should look something like this

git remote add upstream https://github.com/YourName/OriginalOwner/OriginalNameofProject.git
Enter fullscreen mode Exit fullscreen mode

to be sure of the upstream of your fork, type git remote -v again, you should see the URL for your fork as origin and the URL for the original repo as upstream

your output should look something like this

origin  https://github.com/YourName/NameofYourFork.git (fetch)
origin  https://github.com/YourName/NameofYourFork.git (push)
upstream  https://github.com/YourName/RepoNameOriginalofOriginalOwner.git (fetch)
upstream  https://github.com/YourName/RepoNameofOriginalOwner.git (push)
Enter fullscreen mode Exit fullscreen mode

Now, your forked project will be synced with the upstream repo, it is good practice to always sync your fork with the upstream repository after cloning to your local machine.

So, you have successfully spotted an issue in an open source project, the issue has been assigned to you, you’ve forked and cloned it to your local machine also, but before you start working on it, it is very important to create a branch.

Create a branch

Few git branch commands and their functions to have at your finger tips.

git branch
current branch you’re working on
git branch -r
all remote branches
git branch -a
all remote branches local and remote
git checkout
shows a record of all the commit in your current branch.

Now, we create a new branch using the git checkout command.
git checkout -b [branch name]

Making changes

After you’ve successfully resolved the issue, git takes a record of every change made in that repo to see the changes that has been made we use the git statuscommand on a windows environment these changes will be highlighted in red.

Commit changes

Once you're sure that the changes made solve the issues raised, next, you need to add these changes to the repo with git add . and commit these changes with
git commit -m ‘a commit message summarizing what you did’

Pushing changes

Now we need to make our changes visible remotely by pushing these changes using git push but before we do that we need to be sure of the name of the remote, some repo use main others master or origin

by using the command git remote you’ll see the remote name used for the project
Image description

once you’ve successfully identified the remote name, you can now successfully push with git push [repo name] [branch name] for the case of this article, the remote name used in demoing this article is origin and the branch name is register-models so your git command will be something like
git push origin register-models

Making a pull request

Once you’ve successfully pushed your code, the next and final step will be to make a pull request, that is alerting the maintainer of the project that a change has been made and a merge is needed

*CLICK * on the compare & request icon

Image description

Fill up the fields with the necessary information and click create pull request, Congratulations you have successfully made your first contribution to an open source project, if your PR is accepted you’ll receive a mail.

Conclusion

It is okay to google the solutions to an issue no one will penalize you for doing that, what is important to contributing to an open source project is solving the issue, and also very important to note is that your PR might not be merge do not take it personal or feel less skilled to keep contributing to more projects, it might be that your approach to tackling the issue isn’t a maintainable or clean approach, you can always seek help from contributors on how best to contribute if your PR isn’t merged.

Top comments (1)

Collapse
 
andisiambuku profile image
Andisi (Roseland) Ambuku

Great introduction to open source