How to make a Pull Request on Github?

A Pull Request is a feature of Git where a contributor asks a maintainer of Git repository to review code that they want to merge into the main branch of a project.

The following steps are involved in making a Pull Request on Github:

Fork the Repository

The first step is to fork the Github project repository.

Fork a Github repository

When you are on the Github project repository page that you want to contribute, click on the fork button. This will create a new copy of the entire project repository under your Github account.

Clone the Repository

Once the project repository is under your account, clone it to your local machine.

Fork a Github repository

Open the terminal or command prompt on your computer and run the clone command as shown below:


git clone <Repository HTTPS address>
Example:
git clone https://github.com/tutorials-buddy/myapp.git

After the project repository is cloned to your local machine, navigate to the cloned project directory:


cd your_cloned_project

Create a New Branch

Now, create a new branch by running the following command:


git checkout -b <New Branch Name>
Example:
git checkout -b new_branch_name

Add your Code and Commit them

After you are done making changes or adding your code, run the following command to check the changes:


git status

On running the above command, you'll see the changes in red.

Add those changes to your branch by executing the following command:


git add .

Now, commit those changes by running the following command:


git commit -m 'your commit message'

Push your Changes to Repository

Push your new branch with changes to the Github repository by running the command:


git push origin <new_branch_name>

Create a Pull Request

Now, go to your Github repository of this project and click on the Compare & pull request button as shown in the image below:

Fork a Github repository

Next, when you are taken to the create pull request page, write about the changes in detail in the comment textarea and click on the Create pull request button.

Fork a Github repository

Your pull request allows the repository maintainers to review your contribution. If everything is good, they may accept and merge it.

Congratulations! you have learned how to make a pull request on Github.