Working Code for Raspberry Pi Projects for the GrovePi

I have Python code and helpful docs for both the ‘Who’s At The Door’ and ‘Sensor Twitter Feed’ projects. What is the best way to share them with the GrovePi community? I don’t know how to use Github for this, if that is the best way.

That’s fantastic, thanks for making the contributions. One way, if there are just code changes, is to make a pull request on Github. Another is to setup your own Github account and we can link to it. Finally, if you have documents or any other materials to share, you can send us a link, and we can post it into the GrovePi pages.

I contribute my code to the GrovePi repo on the DexterInd organisation on GitHub using Pull Requests.

Firstly I forked the GrovePi repo onto my personal GitHub account.

Click the fork button on GitHub.

cd development
git clone
cd GrovePi

Next I added the GitHub - DexterInd/GrovePi: GrovePi is an open source platform for connecting Grove Sensors to the Raspberry Pi. repo as an upstream, so I can fetch other peoples changes by rebasing my master branch.

git remote add upstream
git fetch upstream

If my master branch is outdated and behind the DexterInd/GrovePi master branch, I rebase my master to fast forward it and inherit other peoples changes.

git checkout master
git pull --rebase upstream master
git push origin master

I keep my master clean and only commit code to feature branches. This lets me have multiple independent branches for fixes / contributions. If you are using Pull Requests, you need to use separate branches to avoid unintentional commits tailing onto the end of the pull request. If you make additional commits on a branch that has an unmerged pull request, the commits will be included if it gets merged.

Create a feature branch

git checkout -b my-feature

Add some code, commit, and push to your GitHub fork

git status
git diff
git add .
git commit -m "Title of the feature"
git push origin my-feature

Open 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 Dexter Industries admins approve the changes, they click the merge button and 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 ontop of theirs and resolve conflicts. Admins wont be able to merge your PR if there are conflicts.

git checkout my-feature
git pull --rebase upstream master

After you have resolved all of the conflicts, you’ll need to force push to your changes to your branch. A force push overwrites the existing changes on GitHub with what you are pushing. Careful, it’s not reversable.

git add .
git rebase --continue
git status
git push -f origin my-feature

If GitHub cant automatically merge your PR, you might also need to --rebase and force push.

Here is a good article on Forking + Pull Requests:

If command line is not your thing, and you use a Mac, GitHub has an easy to use app:

Hi mike,
Thanks a lot for explaining how to contribute to Dexter Industries with Github.

This post looks so good that we might add this to the site explaining people how to contribute code to our Github repo.

Thanks again for explaining it to everyone,