Working on your first open source issue | Git →03

My Most important Git article. Ever.

ALOK HEGDE
4 min readJul 31, 2022
Photo by Luke Chesser on Unsplash

Contributing to an open source project is amazeballs, but first, make sure you have :

1. A GitHub account and,

2. Git installed on your computer.

Now all you have to do is to find an issue on an open-source project to work on.

I would recommend you to work on issues that have been labeled as a good first issue.

They are the issues that are made for first-time contributors.

After finding your first cute little issue, the next step is to FORK.

Fork the project in every position possible.

What is forking?

Forking is creating a copy of the project onto your account on GitHub.

Not the forking you thought, you pervert.

To fork a project, visit the project page and click the “Fork” button at the top-right of the page.

After a few seconds, you’ll be taken to your new project page, with your own writeable copy of the code.

The fork button.

The flow of development in open source contribution:

  1. Fork the project
  2. Create a topic branch from master.
  3. Make some commits to improve the project.
  4. Push this branch to your GitHub project.
  5. Open a Pull Request on GitHub.
  6. The project owner merges or closes the Pull Request.

After forking the project, the next step would be to clone the project, which you can do by typing:

git clone <url>

When you do this, it creates a copy of the forked project on your local machine, ready for you to work on the issue.

Now, what if the changes you have done break the code, or even the entire project as a whole??

It is a good idea to create a new branch or a separate development path where your code doesn’t affect the actual codebase unless the code is merged.

You can do this by typing:

git checkout -b <issue number>

Issue number is just the number of the issue you are working on.

Here the -b tells you are creating a new branch and not checking out a branch that is already present.

The next step would be to open this folder inside a development environment or a text editor and get those code juices flowing.

After you have worked on your issue, what do you do now? How do you make sure those changes take place on GitHub as well?

Using git commit.

You have to make sure all your code has been staged for committing.

You can do this by typing :

git add .

This tells git that you want all the files in the directory to be staged for the commit.

The next step is to write a commit message explaining what changes you have made, in one or two lines.

You can do this by typing :

git commit -m “commit message”

After you type this, your code has become ready to be pushed onto the GitHub repository so that it can be reviewed by the maintainers before they merge your code onto the original codebase. Right now, your code is not with the original codebase, but on a different codebase, or a branch.

You can push your code by typing:

git push origin <name of the issue>

Problems that may arise:

1. You might have to enter your password and username.

This is can be easily fixed. Just type in your password and username, and you are done.

2. The git push won’t work.

Just type git reset and try typing this again:

git add. , git commit -m “message” and git push origin <issue name> 

The best advice would be to check out why you are getting the error on StackOverflow, or ask someone who has already contributed to a project.

Pull requests:

Now if we go back to our fork on GitHub, we can see that GitHub noticed that we pushed a new topic branch up and presents us with a big green button to check out our changes and open a Pull Request to the original project.

If we click that green button, we’ll see a screen that asks us to give our Pull Request a title and description.

It is almost always worthwhile to put some effort into this since a good description helps the owner of the original project determine what you were trying to do, whether your proposed changes are correct, and whether accepting the changes would improve the original project.

Now that you created a pull request, all your work is done, now the project owner has to just review your code and merge the pull request you have created.

Do let me know if you have any errors in the comment section.

Eagerly waiting for you….

Also remember, it is — add, commit, then push your code.

Thank you and have a nice day.

--

--