What is Pull Request?
Pull requests let others know about changes you’ve pushed to a branch of your repository on GitHub. When a pull request is opened, you can discuss and review potential changes with collaborators and add follow-up commits before the changes are merged into the base branch.
Prerequisite:
GIT is installed on the machine
Valid account on GitHub
Implementation Steps
If you want to create a new branch for your pull request and do not have write permissions to the repository, you can fork the repository first.
1. Fork the repository
By clicking the fork button at the top of the page, you can fork the repository. This will make a copy of the entire repository in your account. To know more about Forking, please refer to this tutorial – How to Fork a GitHub repository.

2. Clone the repository
Once the repository has been added to your account, you can clone it to your machine to work with it locally.
Clone by clicking the clone button and copying the link as shown below.

Open the terminal (GitBash) and run the following command. It will clone the repository locally.
$ git clone https://github.com/vibssingh/GitHub-Demo.git

Now we have set up a copy of the master branch from the main online project repository.
We need to go to that cloned directory by running this command:
$ cd GitHub-Demo
3. Create a new branch
When working with repositories, whether it’s a small project or contributing to the work of a group, it’s the best practice to create a new branch.
The branch name should be short and reflect the work we are doing.
Now, use the below command to create a branch:
$ git checkout -B first_merge

4. Make changes and commit the changes
Make essential changes to the project and save it.
Then execute git status, and you’ll see the changes.
$ git status

Add those changes to the branch you just created using the below command:
$ git add .

Now commit those changes using the git commit command:
$ git commit -m "First Change by Vibha"

5. Push changes to GitHub
In order to push the changes to GitHub, we need to identify the remote’s name.
$ git remote

For this repository, the remote’s name is “origin”.
After identifying the remote’s name we can safely push those changes to GitHub.
$ git push origin first_merge

6. Create pull request
Go to your repository on GitHub, and you’ll see a button “Compare & pull request” click it.

Please provide the necessary details on what you’ve done (You can reference issues using “#”). Now submit the pull request.

7. Update the Local Repository
Before submitting any pull requests to the original repository, you must first sync your repository with it.
While working on a project with other contributors, keep your local repository up to date with the project because you don’t want to make a pull request for code that will automatically cause conflicts (though in collaborative code projects, conflicts are bound to occur). You’ll need to sync changes to keep your local copy of the code base up to date.
To update/sync those changes to your master branch, follow these steps:
1. First, check which branch you are in.
$ git remote
It’ll list all branches and indicates the current or active branch in green.

2. Switch to the master branch
git checkout main

3. Add the original repository as an upstream repository
In order to pull the changes from the original repository into your forked version, you need to add the original Git repository as an upstream repository.
git remote add upstream https://github.com/original-owner-username/original-repository.git

4. Fetch the repository
Fetch all the changes from the original repository. Commits to the original repository will be stored in a local branch called upstream/master.
$ git fetch upstream

5. Merge the changes
Merge the changes from the upstream/master into your local master branch. This will bring your fork’s master branch into sync with the upstream repository without losing your local changes.
$ git merge upstream/main

6. Push changes to GitHub
At this point, your local branch is synced to the original repository’s master branch. If you want to update the GitHub repository, you need to push your changes.
$ git push origin main

Congratulations! You’ve made your first pull request.