Create your first pull request here!

Step by step guide to create your first pull request

Shubham Patil
6 min readJun 25, 2018
GitHub Workflow

I remember when I first started to learn to get into the open source, I couldn’t find proper resources or tools. Everything was scattered on the web and it was difficult to fit everything into one place.

I started learning git first. Once I got familiarize with it then I thought now what? Where to use this? Then I thought maybe I should start contributing to open source projects. So I started exploring GitHub repositories to find some project which interested me. But there were so many projects and it was very difficult for me, as a beginner, to understand the open source world! It took me almost 2–3 months to just create my pull request. Once I did that I found everything was so damn easy. You go to a repository, read their documentation and understand the contributing guidelines and you are good to go. You can go ahead and solve some of their issues or add a new feature to their software or just simply play with it on your local machine!

I feel that it’s just the first pull request that keeps you low on confidence and confused! And that’s why I thought of writing this article. As we go ahead you’ll get to know about git and GitHub workflow (we use GitHub but it will be exactly same for other platforms as well.) And by the end of the article, you will have created your first PR! So let’s get started!

What is git?

Git is a version control system. It basically means that git helps you track the changes in your files for different versions for your own self or when more people are working on the same project. When you start with a project, it might happen that you want to discard the changes just created or try some new feature but don’t want to disturb the project, in such case you need git which help you to keep the mess aside and the original project intact.

There are some beautiful courses which will help you get started with git and give a basic idea of what it is. I am listing down some resources. Codecademy, Udemy, Github.

What is GitHub?

GitHub is hosting service for version control using git where organisations or humans host their code-base. Let’s take an example of VLC Media Player. On GitHub, here is the code-base of the application. As the organisation is public we can see this entire code-base and if interested go ahead and start contributing to it.(We’ll see ‘how to’ soon!)

Also, on GitHub, you can also create your own repositories for your own projects. If other people find it interesting then they will contribute it as well and that is how the community grows and open source project gets its meaning. So when we say Linux or Mozilla is open source then it simply means that someone, somewhere in the world started these projects and uploaded to GitHub or some other such hosting service websites and when people found out about these projects, they started contributing towards them and that’s how their respective communities grew. Above mentioned projects have one of the largest open source communities in the world.

Steps to Create Your First Pull Request

As we already saw, git is used for version control of your project. Here, we will see only those commands which are important for your first pull request. You can get deeper into git and its use by taking some advanced course. I’ll primarily show the commands in context with GitHub but it will be more or same for the other platforms.

Here, I am creating a repository in my GitHub account. We’ll go step-by-step how you can contribute to this repository thereby making your first open source contribution!

First-Pull-Request is the repository I have created. It is a public repository meaning that anyone can contribute to it. So click on this link and get ready with your terminal or command prompt.

1. Fork the repository

The repository you want to contribute it is somebody else’s. You cannot directly make changes into that source code. Therefore, first you need to fork the repository. This created a copy of that exact same repository into your account. So find the fork button on the top right corner of the page of the repository and click it. Now following steps are to be followed on this forked repository which will be in your account in GitHub.

2. Clone the existing repository

Now that you have created a copy of the repository in your account, you can play with the source code and actually make some changes. Follow the steps below to proceed.

It is always better to copy the source code on your machine and then edit/ play with the code. So, before pushing your code you can run it and see if everything is working as it is supposed to!

To clone the repository, click the green button on the repository and copy the URL and open terminal and type the following command.

git clone ‘URL you just copied’

For example:

git clone https://github.com/shubham76/First-Pull-Request.git

3. Create a branch

Once you have the repository on your local machine, go to the directory.

Once you are inside the repository, you should create a new branch for your contribution. This should be done because you don’t want to mess up the master branch code or any other branch code as it may get confusing later.

So, we create a new branch, preferably with the new feature name, with the following command.

git checkout -b <branch-name>

For our purpose, you can write the name of your branch as your username.

4. Make the changes

Now open the repository on your favorite editor. (I prefer sublime text 3.)

This is the main part of the story. You add your code here. Create new feature, fix bugs etc. Once you are done, make sure you run the code and see if it is working properly on your machine.

For our repository, open the README.md file and copy the template and add your details and put it below the last entry. Once you are done, go to the terminal again.

Now you have to add the changes you made to your branch.

git add README.md

Now commit the changes so that the changes are finalized.

git commit -m "commit message"

5. Push your changes to the GitHub

Now that you have to push the changes from your local machine to GitHub account.

git push origin <branch-name>

Enter the username and password.

Now if you go to your GitHub account, you can see the changes you made reflected there under the new branch you created.

6. Submit your changes by creating a pull request

This is the final step. Go to the repository on GitHub. There you will see a compare & pull request button. Click on that button.

Compare & pull request

Then you’ll see the following box. Write comments about your added code or feature so that the maintainer(in our case me!) can understand what this pull request is about. Now click on Create pull request button!

Submit pull request

There you go! You have just submitted your first pull request! After your pull request, the maintainer will have a look at your code and may ask you to change some stuff. Once he/she is satisfied your pull request will be merged & your changes will reflect into their software. In our case, the changes will be on https://shubham76.github.io/First-Pull-Request/ this site.

This was all about creating your first pull request! This is very easy to understand! Once you have your first pull request, you’ll get enough confidence to get going! Welcome to the open source world!

To get used to the commands print out this cheat sheet and paste them on your working desk!

Do let me know in the comments if you run into some problems!

Happy Coding ☺

--

--