In team-based software engineering workflows, merging code directly into primary branches like master or main is generally discouraged. To maintain code quality, ensure automated testing passes, and prevent breaking changes from reaching production, teams utilize Pull Requests (PRs) (also known as Merge Requests).
At the core of any Pull Request is the git merge operation. Merging is Git’s way of combining the histories and changes of two branches together. When you run git merge <source-branch> while active on a <target-branch>, Git locates a common ancestor commit between the two branches and integrates the changes.
Depending on how the commit histories of the two branches have progressed, Git performs one of two main types of merges:
A fast-forward merge occurs when the history of the target branch has not diverged since the source branch was created. Since no new commits have been added to the target branch in the interim, Git merges the branches by simply moving the target branch’s pointer forward to the tip commit of the source branch.
A three-way merge occurs when both the source and target branches have diverged (meaning new commits have been made on both branches since they split). Git uses three commits to generate the merged state:
Git combines the diffs and automatically creates a new commit—a merge commit—which has two parent commits. If changes overlap in conflicting ways, Git halts the merge and prompts the developer to resolve conflicts manually.
A Pull Request is not a native Git command, but a server-side feature provided by collaborative platforms (such as Gitea, GitHub, and GitLab). It acts as a wrapper around git merge to facilitate code review and control:
gitGraph
commit id: "Initial Commit"
branch "story/fox-and-grapes"
checkout "story/fox-and-grapes"
commit id: "Added fox-and-grapes story"
checkout main
commit id: "Other updates on master"
merge "story/fox-and-grapes" id: "Merge PR #1 (Merge Commit)"
sarahstory-blogmax (credentials: max / Max_pass123)tom (credentials: tom / Tom_pass123)story/fox-and-grapesmasterAdded fox-and-grapes storyAccess Gitea via the browser and log in as max. In the dashboard feed, verify that Max’s recent commit (d4ec5da821) on the story/fox-and-grapes branch has been successfully pushed.

Navigate to the repository page at /sarah/story-blog. Gitea will display a green banner indicating that story/fox-and-grapes was recently pushed. Click on the New Pull Request button on the right side of this banner.

Ensure the branch targets are correctly configured:
masterstory/fox-and-grapesEnter the title Added fox-and-grapes story in the title field.

Before clicking Create, or from the newly created PR page:
tom from the dropdown list to request his approval.
max and log in with Tom’s credentials (tom / Tom_pass123)./sarah/story-blog and open the PR.
tom approved these changes.
Once the pull request merges successfully, Gitea will display a purple Merged status.
story/fox-and-grapes must remain intact.
Under the /sarah/story-blog repository homepage, switch the branch dropdown to master. Verify that the file fox-and-grapes.txt is now present in the file explorer.
Go to the Commits tab of the master branch. Check that the merge commit has been created at the top of the history:
Merge pull request 'Added fox-and-grapes story' (#1) from story/fox-and-grapes into master
Verify that the author is tom and the original commit author was max.