This document explains the concepts and process of creating Pull Requests (PRs) and merging branches in Git. It is designed to help to understand how to contribute changes to a shared repository, collaborate with others, and maintain a clean and organized codebase. This includes creating PRs, reviewing changes, resolving merge conflicts, and finalizing the merge process.
A Pull Request (PR) is a way to propose changes to a codebase. It allows developers to notify team members about changes they've pushed to a branch in a repository, usually with the intention of merging into the main or development branch after review.
# Tom's branch
git checkout -b tom/update-navigation
# Jerry's branch
git checkout -b jerry/update-contact- Make Your Changes
Edit, add, or delete files as needed.
- Stage and Commit Your Changes
git add .
git commit -m "Add my new feature"- Push the Branch to Remote
git push origin feature/my-feature
# Tom's branch
git push origin tom/update-navigation
# Jerry's branch
git push origin jerry/update-contact- Create a Pull Request
Go to your repository on GitHub/GitLab/Bitbucket and:
Click on Compare & pull request
Add a title and description
Assign reviewers if needed
Click Create pull request
- Review and Approve
Team members can:
Add comments
Request changes
Approve the PR
- Merge the Pull Request
Once approved, you can merge:
Click Merge pull request
Confirm the merge
Optionally delete the branch after merging
Alternatively, from the command line:
git checkout main
git pull
git merge feature/my-feature- Pull Latest Changes
After merging, make sure everyone updates their local copy:
git pull origin mainIf you encounter merge conflicts:
git status
# Edit the conflicting files to resolve manually
git add <resolved_file>
git commit✅ Best Practices
Always branch off from the latest main or develop.
Keep PRs focused and small.
Write clear PR titles and meaningful descriptions.
Review code carefully before merging.
Delete stale branches after merging to keep the repo clean.
📚 Resources










