How to contribute on GitHub - A Guide

This post was originally to ask for help in contributing on GitHub, which I found utterly confusing at first, so now I’m leaving this guide for anyone who finds themselves in the same position.

I’m using the Windows command prompt, so Mac/Linux users will have to change the directory separator character seen below.

Part 1
First, get a GitHub account, go to the OGS repo, and fork it.

Now you have your very own copy of the latest code, but only on GitHub. You want it on your computer, so after installing git, go to whatever directory you want to work from, clone your repo, and change to the new folder.

cd myGitHubRepos
git clone https://github.com/YOUR_USERNAME/online-go.com
cd online-go.com

Part 2
For every feature/issue you work on, you need to make a separate branch. Make sure to git checkout devel each time, and create the new branch (let’s call this one myFirstBranch) from that with git branch.

cd myGitHubRepos\online-go.com
git checkout devel
git branch myFirstBranch

To start making changes to this branch, switch to it with

git checkout myFirstBranch

You can check which branch is currently active with

git branch

Part 3
Now use your favourite editor to make changes, and when you’re ready, git add files to the staging area, either with file names/patterns (if you don’t want to commit certain changes yet), or add all changed files by using a period.

git add path\to\first\file.tsx path\to\other\files\*.tsx
or
git add .

You can use git add multiple times, and then confirm with

git commit

This opens an editor for the commit message (the first line is the title, and subsequent lines are the message), but you can avoid the editor by adding some command line arguments.

git commit -m "Commit Title" -m "Commit message"

So far, everything is still happening locally. To push it to your GitHub account use the following command (you’ll need your GitHub credentials).

git push https://github.com/YOUR_USERNAME/online-go.com myFirstBranch

Part 4
To let the original repo know that you want to share changes, you must open a Pull Request (PR). Go to your fork on GitHub (https://github.com/YOUR_USERNAME/online-go.com) and select your new branch via the Branch button on the left, then click the New pull request button beside it.

This will bring you to the Open a pull request screen. The base fork and base branch, and head fork and compare branch should be correct, but it never hurts to double check that they are online-go/online-go.com; devel, and YOUR_USERNAME/online-go.com; myFirstBranch respectively.

Add a pithy title to describe the PR, maybe mentioning the number of the issue it’s fixing, and a more detailed explanation below it. Finally, click the big green button to confirm the PR.

githubPRSConfirm

Congratulations! You’ve opened your first Pull Request! When you want to start work on another issue, repeat the instructions beginning from Part 2.

Outro
There are niceties and nuances to git that I’ve left out because they’re not absolutely necessary right now (for example, you might want to read about rebasing) or because I don’t know about them yet, but I hope this guide helps you get started. If there are any errors or improvements to make, let me know.

I’m working on a few things, and trying to submit them as separate pull requests. I’ve got one pull request done properly, but when I try to make a different one it ends up as part as the original. So, can anyone provide an idiot’s guide to contributing multiple pull requests?

Do the second feature on a different branch.

That’s what I tried and screwed up. Can you give me a step by step?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.