how to contribute to Github open source projects

0xdom
Nerd For Tech
Published in
8 min readApr 19, 2021

Have you ever wondered your favorite tool should work the way you wanted or you found a bug or spelling mistake and wished someone could just fix that? well with open-source agenda you can do that or you can just contribute to the project you love using, but if you’re overwhelmed by the process and never tried? I’ve been there too.

In this article, I'm going to show you how you can get started with an open-source project and start contributing to the project in no time.

What does open-source mean?

we’ll start with a simple analogy, let's say your favorite dish is Tacos, now, in this case, Tacos is a product that you consume but to make Tacos you need to have its recipe and you don't have it, you went to the chef and asked for it, “hey can I get Tacos recipe so I can make it at home” if they reject you it’d not be the open-source but if they accept to share their recipe you can call it open-source.

Now you can make your own homemade Tacos but you wanted to improve the recipe according to your own taste and replaced beef with salad, which turned out to be awesome, and shared your modified recipe with the chef now it's up to them to decide whether they want to add this recipe to the menu or not.

But hey you made your first contribution wooho!

The same goes with open-source, it is the software for which the original source code is made freely available and may be redistributed and modified.

Benefits of contributing to open source

  • It makes you stand out.

when you start contributing to the open-source projects. You immediately get in contact with the people who’re already working on the same project. And trust me by contributing to the open-source project you’re building your real-life resume and it’ll gain the attention of your future recruiters.

  • It helps you improve your skills.

contributing to the open-source projects is a fun activity it helps you to work on your coding skills, don’t know coding? no problem you actually don’t need to learn coding to contribute to the open-source project. either way, it will definitely help you improve your people skills.

  • It makes you feel good.

yes, It makes you feel good about yourself that you’re not just consuming but actually giving back to the community, and helping the project to grow.

Getting Started

To contribute to the open-source project first you need to find a project you want to contribute well duh...

I’d suggest you, contribute to the project you already know and use, so this way you’d have a good understanding of how the project works.

my personal favorite is pwnagotchi (which is Ac2 based AI for performing authentication and association attacks on wifi networks.)

Step 1: Sign in to GitHub

sign into your Github account, if you don’t have one create it here.

Step 2: Forking the project repository

Find the project you want to fork and go to its repository page you’d see something like this. Notice evilsocket which means I'm on the original pwnagotchi repository.

pwnagotchi home repo

You can read the README.md this is the file where information about the project is given. Also, check the contributing guidelines before forking the project.

After forking the entire project will be copied to your own repositories.

copied in my repo

Step 3: Clone the repository

Now you need to clone the repository to your device to work on the project, click the green button from there you can download the project via the browser or you can clone it using your terminal.

Clone the repo

I'm going to clone the repository via terminal if you're on windows you can use the git terminal to clone the repo you can download the git terminal from here, you can clone the repo with the following command.

$git clone <link>

I used

$git clone https://github.com/CyberBotCreator/pwnagotchi.git

Step 4: Navigate to the repository

You can navigate to the downloaded repository by using the following command.

$cd <dir-name> 

in my case

$cd pwnagotchi

Step 5: Making a branch

if you want to make changes you should make changes off of the master so that way your changes won’t affect the master (main public repository).

Also with the open-source, there are lots of updates coming at a different time and you wouldn’t want your changes to affect anyone else's changes. so you should make changes on a separate branch.

the following command will show you which branch you’re currently on.

$git branch
master*

you can see we’re on master branch notice ‘*’

now we need to make a new branch for us to work on as shown below. Use any name you want I’ll just use ‘my-contributions’

$git branch my-contributions

Step 6: Switching the branch

we’re still on the master branch you can check that with the git branch command. so for switching our branch to the branch we made use of the following command.

$git checkout my-contributions
Switched to branch 'my-contributions'
changing branch

so we’re on the ‘my-contributions’ branch now, everything in the ‘my-contributions’ branch links back to ‘master’ and vice-versa means we can pull all of our new updates from ‘master’ or ‘my-contributions ’ to the ‘master’.

So now you can open your favorite IDE (Integrated Development System) and start making changes.

Step 7: making changes

first of all open the cloned repository in your favorite IDE, I’m gonna use Pycharm here.

for demonstration purpose, I’ll add a comment in the code.

comment added

here you can see I added a comment on line 103, as you can see Pycharm does a very great job of highlighting the changed line (green mark in front of line number)

Either way, you can see the changes made in the git terminal with the following command.

$git diff
changes made

you can see the changes made in the git terminal showing in the green color.

Step 8: Syncing with master

The changes you made are local to you only so you need to be in sync with the ‘master’ (the main pwnagotchi repo), in case any updates have made to the main repo you can use the following command to be in sync with the original master ( which is pwnagotchi repo).

you need to change your current branch to the ‘master’

$git checkout master

and you can see we’re already in sync with the original repo.

changing branch

so now we need to pull from the original master to our current repository eg. cyberbotcreator/pwnagotchi in my case.

$git pull
pulling from original repo to our own

as you can see here we’re already up to date here. Also, its a good practice to be in sync with your ‘master’ on the ‘my-contributions’ branch. You can do that by going on the ‘my-contributions’ branch and pull from ‘master’.

$git checkout my-contributions

and pull from ‘master’ to ‘my-contributions’ branch.

$git pull 
pulled from master to my-contributions

so for syncing ‘my-contributions’ with the ‘master’ you can copy the command shown in the output and change the <branch> to the ‘master’ meaning it will sync the data from ‘my-contributions’ to the ‘master’ (local) branch.

so in my case

$git branch --set-upstream-to=origin/master my-contributions
It copied data from ‘my-contributions’ to ‘master’

Step 9: Submit these changes

So we’re all good, lets submit these changes to our Github repo.

we use this command to group all of the files we changed together into one instance.

$git add .

now you add a commit message this will describe what your changes mean, you can add a comment there.

$git commit -m "described code through comment"

and now you can push these changes.

$git push
pushed the changes

now to push these changes by using the command in output might be different for you.

$git push origin HEAD
pushing the changes

Step 10: Making a pull request

so back at our Github repo if you see this message your changes have successfully pushed to your repo.

our Github repo

So click on ‘compare & pull request’ to make a pull request.

Below you can see how it shows what we’re doing, we’re pushing the changes to the ‘master’ of base repository ‘evilsocket/pwnagotchi’ and the changes are coming from our head repository from ‘my-contributions’ branch.

making pull request

below that, you will see our commit message you can also describe what these changes mean and their description.

add commit message

after making the pull request it will be available in the main pwnagotchi repo in the pull requests tab now you have to wait for the viewers (people with the higher contribution in that project) to comment and if your changes are good enough to satisfy viewers, they will merge your request into their main master branch.

Congratulations you have successfully contributed to an open-source project.

--

--

0xdom
Nerd For Tech

I'm a cybersecurity aspirant currently working on my skills, wannabe hacker.