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.
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
.
git checkout feature-branch-local
git merge origin/main
Merge the changes from the main
branch into your local branch. If there are conflicts, Git will notify you.
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.");
git add <example_file.txt>
Commit the changes with an appropriate commit message.