Writing and maintaining open source code is difficult but rewarding. There are a lot of open source projects out there such as Linux, VLC Media Player, Python, Nodepad++ and many more. Many project rely on an army of volunteers to make the project move forward. These volunteers write the code, patch bugs, test the code, write the documentation and do almost everything for the project. No matter how small the contribution, it still counts.
A big challenge for people who want to contribute to the Open Source code is where to start. Often, it may feel overwhelming to start and potential contributors get confused and give up.
All the code for Dexter Industries products is Opensource and we love to have other people go through it, find bugs and comment on it. It makes the product better for everyone and there is a small satisfactions that you have contributed to an Open Source project.
A while back, a user on our forums asked how to contribute code for GrovePi (original post here) and another user mcauser (Thanks again!) wrote an excellent reply that compelled us to write a post which should help other people start contributing to Open Source too.
We use Git in all our projects and collaborate using Github. This lets all our users tinker around and contribute to the codebase. Also we want to make our product the best out there and any help from the community is greatly appreciated.
We have modified the post a bit so that it is much more easier for people to follow. Your open source journey starts here:
- Create an account on Github if you already don’t have one. Create if from here
- Once you create an account you will be redirected to your profile. It should look similar to the one below.
- Now the next thing to do is to fork a project that you want to work on. Forking creates a copy of the original project for yourself that you can work on. When you are done making the changes, you can send those changes back to the Original Project.
Here, we will show you how to contribute code to GrovePi, but you can easily do it for our other Project too like BrickPi and GoPiGo.
To Fork a project, just open the project Github URL (https://github.com/DexterInd/GrovePi) and click on Fork on the top right corner. - After you have forked the repository, you’ll be taken to your account and a copy of the original code will be created. You can also see the HTTPS clone URL on the right side which you can use to create a local copy of the project.
- Now the next step is to Clone the repository, which means to create a local copy of the code which you will be working on. For this first create a directory where you’ll be working from like development:
mkdir development
Open the folder
cd development
and clone the repository
git clone https://github.com/your_user_name/GrovePi.git
Tada, the repository is cloned now, open the GrovePi folder to see the files
cd GrovePi
- Next, add the https://github.com/DexterInd/GrovePi repo as an upstream repository, so that you can add the changes that other people make.
git remote add upstream https://github.com/DexterInd/GrovePi.git
git fetch upstream
- If your master branch is outdated and behind the DexterInd/GrovePi master branch, then you’ll have to rebase your master to fast forward it and inherit other peoples changes and push it to your Github repository.
git checkout master
git pull --rebase upstream master
git push origin master
- It is better to keep the master branch clean and only commit code to feature branches that you create. This lets you have multiple independent branches for fixes / contributions.
Create a feature branch where you’ll make changes to the code:git checkout -b my-feature
- Add some code, commit it, and push it to your GitHub fork:
git status
git diff
git add .
git commit -m "Title of the feature"
git push origin my-feature
- Open github.com and go to your fork. You should see a yellow bar prompting to create a pull request. Otherwise click on the branches tab and there will be buttons next to each.
Once the admins approve the changes your code gets copied across. After this, you can safely delete your feature branch.
If someone has made some conflicting changes you’ll need to rebase your changes on top of theirs and resolve conflicts. Admins won’t be able to merge your pull request if there are conflicts. - If GitHub can’t automatically merge your PR, you might also need to do a rebase and a force push.
Here is a good article on Forking + Pull Requests:
https://help.github.com/articles/using-pull-requests/
If command line is not your thing, and you use a , GitHub has an easy to use app:
https://mac.github.com/ or https://windows.github.com/
Hope that you made it this far and that your first pull request is on the way.
Post on the forum to celebrate your first code commit or ask about any challenges along the way!