Skip to content
Parwaz DigitalMarketing · Web · Courses

Web Development Course · Module 4, lesson 4

Branches, pull requests and merge conflicts

Work on features safely with Git branches, propose changes through GitHub pull requests, and resolve merge conflicts when they happen.

What you will learn

  • Create, switch between and merge branches
  • Open a pull request and review changes on GitHub
  • Resolve a simple merge conflict

A branch is a separate line of work. The main branch should always hold working code. To build a new feature, run git switch -c add-contact-form to create and switch to a new branch. Commits made there do not affect main until you merge them. You can switch back with git switch main at any time, and list branches with git branch.

On teams, branches are merged through pull requests. You push your branch to GitHub and open a pull request asking to merge it into main. Teammates review the changes line by line, leave comments and approve. Automated checks, such as tests, often run at this stage too. Even working alone, pull requests give you a clear record of each feature and a moment to review your own work.

A merge conflict happens when two branches change the same lines differently. Git marks the conflicting section in the file with <<<<<<<, ======= and >>>>>>> lines showing both versions. You edit the file to keep the correct result, delete the markers, then stage and commit. Conflicts are normal. Pulling often and keeping branches short-lived makes them smaller and less frequent.

Practice task

Create a branch, change the footer text and commit. Switch to main, change the same line differently and commit, then merge the branch and resolve the conflict you created.

Web Development Course

Learn this properly,with a final project.

These pages summarise each lesson. The full course teaches them hands-on. Message us for the current fee, schedule, and format.

Available for new projects — Replies within one business day