Make Your First Pull Request! 🚀

Aakanksha Bhende
·Sep 1, 2021·

6 min read

Make Your First Pull Request! 🚀
Play this article

Table of contents

  • First time contributing? Will help you out 🤝
  • Basic Git Concepts ✅
  • 💥 How to Contribute

First time contributing? Will help you out 🤝

Open-source contributions are a great way of learning and practically implementing your knowledge. But often the open-source newbies are confused in selecting the right projects for them to contribute, in creating relevant issues or making a pull request! Refer to the following articles on the basics of Git and GitHub, in case you are stuck:

If you don't have git on your machine, install it.

Basic Git Concepts ✅

Git

Starting with the definition, Git is a free, open-source software which is used commonly used everywhere in the tech industry for version controlling.

Now, what is version control? It simply means managing different versions of a project/product. When multiple developers work on a project, they often distribute their work. Git which supports distributed version control system helps these developers to work (who would be working on different features of the project like UI, Database, etc) on the project simultaneously. Pushing the code (uploading the code on the server from where others can access it) by any of the developers doesn't affect the others. Because of this, if the owner of the project feels to keep an earlier version of the product for market use, he can easily access the older version. But this doesn't mean the newer versions of the product are lost. All the versions are managed properly by Git, which saves the history of all the changes or additions on the project and also tracks by whom they were done.

Repository

It means the project or the product whose changes we need to track using version control. It can be both public and private. Public ones are the ones which are accessible to the whole world and the private ones are accessible only to those to whom the repository owner has given permission. The extension of any repository is .git.

Remote

If I'm building my project, I'll be making it on my local system but later in future if I want my friends to collaborate or any enthusiast to contribute to my project, I'll have to share this project with them too. But how will I share? I can make a remote repository on GitHub or any other platform like GitLab which is based on Git. Then anyone can access the repository from there and contribute to my project.

Branching

Creating a branch in a repository means creating a new version of the project/ product but it is separate from the main repository. This is generally a good practice for the management of the code. As I said earlier, if many developers are working on the same project but on different features, they will create different branches with an appropriate name from the main repository. We can make a branch to solve an existing issue, for adding a feature or for adding enhancements to the project. You can imagine it like an upside-down tree with the main trunk being the main branch and all the other branches created as the ones grown out from the main trunk of the tree.

Merging

Now, if the purpose for creating branches is solved like if the code in my branch solves the existing issue in the main branch of the repository or the code in my branch is having better User Interface, then if the repository owner approves these changes, he/she merges this code with the main branch. Now, the changes which I made on my branch get merged with the main repository. Generally, the main branch of the project is kept production-ready.

Merge conflicts

When two or more developers work on different branches, their work gets approved and when they try merging their branches, sometimes Git is not able to do it as if the developers have changed the same file, Git gets confused about whose change to accept and merge with the main branch. So, in this case, the conflict arises. We need to solve these conflicts manually. After solving the conflicts, Git can easily merge all the branches into the main.

The Three git states-

  • modified

As the name suggests, this means you have modified or added the files you wanted to add to the next version of the project but you haven't added them to the main repository, which is publicly accessible. It is also known as the working directory.

  • staging

This area consists of all the files which you have modified in the current version and want in the next version of the product/project.

  • committed

    This means the code in our branch is saved and merged into the main repository.

💥 How to Contribute

  • Take a look at the Existing Issues or create your own Issues!
  • Wait for the Issue to be assigned to you after which you can start working on it.
  • Fork the Repo and create a Branch for any Issue that you are working upon.
  • Read the Code of Conduct
  • Create a Pull Request which will be promptly reviewed and suggestions would be added to improve it.
  • Add Screenshots to help know what this Script is all about.

How to make a Pull Request

If you think that you can add a new feature or want to fix a bug. You can start contributing by following the below instructions:

  1. Create a folder at your desired location (usually at your desktop).

  2. Open Git Bash Here

  3. Create a Git repository.

    Run command

git init
  1. Fork the repository.

  2. Clone your forked repository of the project.

   git clone https://github.com/<your_username>/repository_name.git
  1. Navigate to the project directory.

    cd <repository_name>
    
  2. Add a reference(remote) to the original repository.

    git remote add upstream https://github.com/repository_owner/repository_name.git
    
  3. Check the remotes for this repository.

    git remote -v
    
  4. Always take a pull from the upstream repository to your main branch to keep it updated as per the main project repository.

    git pull upstream main
    
  5. Create a new branch (prefer a branch name that relates to your assigned issue).

    git checkout -b <YOUR_BRANCH_NAME>
    
  6. Perform your desired changes to the code base.

  1. Check your changes.

    git status
    
    git diff
    
  2. Stage your changes.

    git add . <\files_that_you_made_changes>
    
  3. Commit your changes.

    git commit -m "relavant message"
    
  4. Push the committed changes in your feature branch to your remote repository.

    git push -u origin <your_branch_name>
    
  5. To create a pull request, click on `compare and pull request.

  6. Add an appropriate title and description to your PR explaining your changes.

  7. Click on Create pull request.

Congratulations🎉, you have made a PR to the repository. Wait for your submission to be accepted and your PR to be merged by a maintainer.

If you are looking to make your first pull request, you can try making one here. If you have any doubts please let me know in the comments :)

 
Share this