Let's assume you have a repository on GitHub with a branch named feature-branch that you want to merge into the main branch. The pull request is Pull Request #123.

Step 1: Fetch the Remote Changes

git fetch origin pull/123/head:feature-branch

This fetches the changes from the pull request branch (feature-branch) on GitHub and creates a local branch named feature-branch.

Step 2: Checkout the Pull Request Branch

git checkout feature-branch-local

Step 3: Merge the Changes

git merge origin/main

Merge the changes from the main branch into your local branch. If there are conflicts, Git will notify you.

Step 4: Resolve Merge Conflicts

Open the conflicted files in your code editor. Resolve conflicts and save the changes.

Example (conflicted file):

<<<<<<< HEAD
console.log("This is my change.");
=======
console.log("No, this is the correct change.");
>>>>>>> main

After resolving conflicts:

console.log("This is my change.");

Step 5: Stage the Resolved Files

git add <example_file.txt>

Step 6: Commit the Changes

Commit the changes with an appropriate commit message.