Merging & pull requests in React JS
Course: React JS Training
Topic: Merging & pull requests
Course Link: React JS Training
Demo Link: Register for a Course Demo
1. Merging and pull requests: why they matter
So far in this module you have learned how to create a repository, make commits, and split your work into branches. Branches keep lines of work separate — but separate work is only useful if it eventually comes back together. That is exactly what merging does, and pull requests are the professional way to manage that moment on GitHub.
Imagine a small team building a website. One developer works on a contact form, another fixes the navigation bar, and a third updates the styling. Each of them commits to their own branch. At the end of the day, all three lines of work must land in the shared main branch without overwriting each other. Merging is the mechanism that makes this possible safely, and pull requests are where the team reviews the work before it lands.
- Integration: merging brings finished feature work into the shared branch so everyone benefits from it.
- Safety: Git records exactly what was combined and from where, so history stays traceable.
- Collaboration: pull requests give teammates a place to review, discuss, and improve code before it becomes part of the project.
- Career relevance: almost every company uses this branch-and-pull-request flow, so it is a skill you will use from your first day on a real team — including in React projects, where components are usually developed on feature branches.
2. What merging means in simple words
Merging means taking the commits from one branch and combining them into another branch, so the target branch ends up containing both lines of work.
A helpful analogy: think of a document that two people are editing on separate copies. One person adds a new section, the other fixes the introduction. Merging is the act of producing one final document that contains the new section and the fixed introduction. If both people edited the same sentence in different ways, someone has to decide which version wins — that situation is called a merge conflict, and you will see how to resolve it later on this page.
Two important details about the direction of a merge:
- Merging is always done into the branch you are currently on. If you are on
main and run git merge feature/login, the work from feature/login comes into main.
- Merging does not delete the source branch. It stays there until you delete it yourself, usually after the merge is complete.
3. Key terms for merging and pull requests
These words appear constantly in team conversations, so learn them now:
| Term | Meaning in plain words |
| Base branch | The branch you merge into, usually main. In a pull request it is called the "base". |
| Feature branch | The branch holding the new work you want to merge, for example feature/login. |
| Fast-forward merge | A merge where Git simply moves the branch pointer forward because the target branch has no new commits of its own. |
| Three-way merge | A merge where both branches have new commits, so Git creates a special merge commit with two parents. |
| Merge commit | A commit that ties two branches together and records that a merge happened. |
| Merge conflict | A situation where both branches changed the same lines, and Git cannot decide which change to keep. |
| Pull request (PR) | A request on GitHub to merge one branch into another, with a page for discussion, review, and approval. |
| Reviewer | A teammate who reads the changes in a pull request and comments, requests changes, or approves. |
| Draft pull request | A pull request opened early to share work in progress; it cannot be merged until marked "ready for review". |
4. What actually happens during a merge
Git does not merge files "by feel". It compares three points of history and chooses one of two merge styles.
Fast-forward merges
If the target branch (say main) has no new commits since the feature branch was created, Git does not need to combine anything. The feature branch is simply a few commits ahead, so Git slides the main pointer forward to the latest commit. This is called a fast-forward. No merge commit is created — history looks as if the work was done directly on main.
Three-way merges and the merge commit
If both branches have new commits, Git performs a three-way merge. It looks at three snapshots: the common ancestor of the two branches, the tip of your current branch, and the tip of the branch being merged. It then combines the changes. Because two lines of history are joining, Git records the event with a merge commit that has two parents. This commit is the "knot" that ties the branches together.
When Git refuses: conflicts
If both branches changed the same lines of the same file, Git cannot know which version you want. It stops the merge, writes special conflict markers into the affected files, and waits for you to resolve the conflict manually. Conflicts are normal, not errors — every professional developer resolves them regularly.
5. The syntax of the merge command
The basic form is short:
git merge <branch-name>
This merges the named branch into your current branch. Remember: first switch to the branch you want to receive the changes, then merge. The most useful variations:
| Command | What it does |
git merge feature/login | Merges feature/login into the current branch; fast-forwards if possible. |
git merge --no-ff feature/login | Forces a merge commit even when a fast-forward would be possible, keeping the branch visible in history. |
git merge --squash feature/login | Takes the branch's changes but does not commit them; you make one single commit yourself. |
git merge --abort | Cancels a merge in progress and returns your branch to the state before the merge started. Useful when a conflict gets messy. |
git merge --continue | Finishes the merge after you have resolved conflicts and staged the files. |
git log --graph --oneline --all | Not a merge command, but the easiest way to see the branch structure and merge commits afterwards. |
In the placeholder <branch-name>, the angle brackets mean "put your own value here" — you type the branch name without the brackets.
6. How a merge works, step by step
Whatever the project, the flow is always the same:
- Finish the work on the feature branch and make sure every change is committed. A merge with uncommitted changes can fail or create confusion.
- Switch to the target branch — usually
git switch main — because merging happens into the current branch.
- Run the merge:
git merge feature/login.
- Read the result. Git either fast-forwards, creates a merge commit, or stops with a conflict message.
- If there is a conflict: open the listed files, edit the marked sections to the correct final content, then
git add each resolved file and finish with git commit (or git merge --continue).
- Verify: run the project, check the pages, and look at
git log --graph --oneline to confirm history looks right.
- Push and clean up:
git push the target branch, then delete the finished feature branch with git branch -d feature/login.
7. Worked example: a fast-forward merge
You built a simple login form on a feature branch while main has not moved. Here is the full session:
git switch main
git switch -c feature/login-form
# ...create login.html and edit it...
git add login.html
git commit -m "Add login form page"
Now bring the work into main:
git switch main
git merge feature/login-form
Output:
Updating a1b2c3d..e4f5a6b
Fast-forward
login.html | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
The words Fast-forward tell you Git moved the main pointer ahead to include your commit — no merge commit was needed, because main had nothing new to combine. The feature branch can now be deleted safely:
git branch -d feature/login-form
8. Worked example: a merge commit with --no-ff
Now suppose main has also moved — a teammate updated the footer while you built a search bar. Because both branches advanced, Git must do a three-way merge:
git switch main
git merge feature/search-bar
Output:
Merge made by the 'ort' strategy.
header.html | 6 ++++++
1 file changed, 6 insertions(+)
Git created a merge commit automatically. To see the branch structure clearly:
git log --graph --oneline --all
* f3a9c1e (HEAD -> main) Merge branch 'feature/search-bar'
|\
| * 9d2e4b1 (feature/search-bar) Add search input to header
| * 71c0f2a Start search bar component
* | 5b8d7c3 Update footer links
|/
* a1b2c3d Add project README
The diamond shape shows two lines of history joining at the merge commit f3a9c1e, which has two parents. Even when a fast-forward would be possible, many teams use git merge --no-ff deliberately, because the merge commit documents that a feature branch existed and was integrated as a unit.
9. Worked example: resolving a merge conflict
Conflicts happen when two branches edit the same lines. Suppose you and a teammate both changed the heading in index.html — you on feature/banner, your teammate on main.
git switch main
git merge feature/banner
Output:
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
Open index.html and you will find Git's markers:
<h1>
<<<<<<< HEAD
Welcome to Our Shop
=======
Welcome to the Shop
>>>>>>> feature/banner
</h1>
Reading the markers:
- The line after
<<<<<<< HEAD is your current branch's version.
======= is the divider between the two versions.
- The line before
>>>>>>> feature/banner is the incoming branch's version.
You resolve the conflict by editing the file to the final text you want — keeping one side, the other, or a blend — and removing all three marker lines:
<h1>Welcome to Our Shop</h1>
Then stage the resolved file and complete the merge:
git add index.html
git commit -m "Merge feature/banner, resolve heading conflict"
If you open a conflicted file and realise you are not ready to decide, step back safely with git merge --abort — your branch returns exactly to how it was before the merge attempt. Note that conflicts are decided per file: files changed on only one branch merge automatically; only overlapping edits need your judgement.
10. What a pull request is in simple words
A pull request (often shortened to PR) is a request, made on GitHub, to merge one branch into another — plus a built-in page where teammates can read the changes, discuss them line by line, request improvements, and finally approve and merge.
An important clarification for beginners: a pull request is not a Git command. Git itself only knows about commits, branches, and merges. The pull request is a collaboration feature built on top of Git by GitHub (other platforms offer the same idea under the name "merge request"). The table below separates the two ideas:
| Local merge with git merge | Pull request on GitHub |
| Where it happens | On your own machine | On the GitHub website |
| Who reviews | Nobody, unless you ask informally | Teammates review formally, with comments and approvals |
| Discussion | None built in | Every line can be commented on; the whole change is discussed in one place |
| History record | Merge commit only | Full record: who proposed, who reviewed, who approved, and why |
| Typical use | Solo projects, quick local work | Team projects, anything touching shared code |
On many real projects the shared branch is protected: GitHub blocks direct pushes to main, so a pull request is the only way to get changes in. That is why the PR flow is not optional etiquette — it is often enforced.
11. How a pull request works, step by step
- Push your feature branch to GitHub:
git push -u origin feature/login-form. The -u flag links your local branch to a new branch on GitHub so future pushes need only git push.
- Open the pull request. GitHub usually shows a "Compare & pull request" button right after the push. Choose the base branch (
main) and your feature branch, write a clear title and description of what you changed and why, and submit.
- Review happens. Teammates read the diff (the line-by-line comparison of changes), comment, and either approve or request changes. You can push more commits to the same branch at any time — the PR updates automatically.
- Approval. Once reviewers are satisfied, the PR is approved and the "Merge pull request" button becomes available.
- Merge. A maintainer clicks the merge button and picks a merge method (see the next section). GitHub merges the branch into the base branch.
- Clean up. GitHub offers a "Delete branch" button; accept it. Locally, switch back and synchronise:
git switch main, git pull, then git branch -d feature/login-form.
Two practical habits: open draft pull requests when work is unfinished but you want early feedback, and keep each pull request small and focused on one change — small PRs get reviewed faster and cause fewer conflicts.
12. Worked example: a complete pull request on GitHub
Here is the whole cycle for adding a pricing section to a website, from your machine to the shared branch:
git switch main
git pull
git switch -c feature/pricing-section
# ...create pricing.html, edit styles...
git add pricing.html
git commit -m "Add pricing section with three plans"
git push -u origin feature/pricing-section
On GitHub:
- A banner appears on the repository page: "feature/pricing-section had recent pushes ... Compare & pull request". Click it.
- Confirm base: main and compare: feature/pricing-section. GitHub shows the diff below.
- Write the title "Add pricing section" and a description: what you added, how to test it, and anything reviewers should look at closely.
- Click Create pull request. Reviewers are notified and can comment on specific lines.
- Suppose a reviewer asks you to fix a typo in a plan name. You edit the file locally, commit, and
git push again — the PR updates itself with the new commit.
- After approval, click Merge pull request, confirm, then click Delete branch.
Back on your machine, finish cleanly:
git switch main
git pull
git branch -d feature/pricing-section
Your main now contains the pricing section, the discussion and approvals are archived on the PR page, and the old branch is gone. If you prefer working from the terminal, the GitHub command-line tool offers gh pr create as a shortcut for opening the same pull request without visiting the website.
13. Merge methods on GitHub compared
When you click the merge button on a pull request, GitHub offers three methods. They produce different history shapes, and teams choose one deliberately:
| Method | What it does | History afterwards | Best when |
| Create a merge commit | Keeps every feature-branch commit and adds a merge commit tying them in | Shows the real branch structure, like the graph example above | You want full, faithful history of how work was developed |
| Squash and merge | Compresses all branch commits into one single new commit on the base branch | One tidy commit per pull request; the branch's internal commits disappear | The branch has many small "work in progress" commits that would clutter history |
| Rebase and merge | Replays the branch's commits on top of the base branch without a merge commit | A straight line of commits, no merge knot | The team prefers linear history and the branch is small and conflict-free |
As a learner, the safest habit is to notice which method your team uses and follow it. Whichever method is chosen, the underlying idea from this page stays the same: work happens on a branch, it is reviewed through a pull request, and merging is the moment that work becomes part of the project everyone shares.
14. Keeping a feature branch up to date with main
On a real team, main does not wait for you. While you spend three days on a feature, teammates merge their own pull requests, and your branch slowly drifts away from the shared code. The longer it drifts, the bigger and messier your eventual conflicts become. Professional developers therefore update their feature branch regularly — often daily — by merging main into it:
git switch feature/login-form
git fetch origin
git merge origin/main
Line by line: switch back to your feature branch, download the latest work from GitHub without changing your files yet, then merge that freshly downloaded main into your branch. Any small conflicts appear now, while only you are involved, instead of appearing later in front of a reviewer. After resolving and committing, push as usual — the pull request on GitHub updates itself and shows "no conflicts with the base branch".
Some teams prefer to rebase the feature branch onto main instead of merging, because it produces a straight line of history. The rule that keeps you safe: rebase only branches that you alone have pushed. Never rebase a branch that other people are also building on, because rebasing rewrites commits and would duplicate their work.
15. Reviewing a pull request like a teammate
Reviewing is the other half of the pull request system. Sooner or later every developer sits on both sides of the table, so learn the reviewer's routine now:
- Read the title and description first. Understand what the change is supposed to do before looking at a single line of code.
- Open the "Files changed" tab and read the diff line by line. The diff shows only what changed, which makes review fast.
- Check the essentials: does the code do what the description says? Are there leftover conflict markers, debugging lines, or unrelated changes mixed in?
- Comment on specific lines. Click a line in the diff, write your comment, and ask questions rather than issuing orders.
- Finish clearly: approve, request changes, or leave a comment, depending on what the repository's rules require.
Good review comments are specific, kind, and suggest an alternative:
"This function reads the file twice — could we store the result in a variable after the first read? It would also make the check below simpler."
When you receive a review, treat the comments as free help: reply to each one, push the fixes as new commits, and let the reviewer look again. The pull request thread keeps the whole conversation, so six months later anyone can read why the code ended up the way it did.
16. Undoing and repairing merges
Sometimes a merge goes wrong. Git gives you a repair tool for each stage of the mistake:
You are stuck in the middle of a conflicted merge
If a conflict appears and you realise you are not ready to resolve it, step back completely:
git merge --abort
Your branch returns exactly to the state it was in before the merge attempt. Nothing is lost.
The merge finished locally, but you have not pushed it
If you merged the wrong branch or merged too early and have not shared anything yet, reset your branch to where it was just before the merge:
git reset --hard ORIG_HEAD
ORIG_HEAD is a bookmark Git saves automatically, pointing to where your branch was before the last big operation such as a merge. This trick is only safe before pushing, because it rewinds history that nobody else has seen.
The merge is already pushed and others may have pulled it
Never try to erase shared history with a force push. Instead, create a new commit that undoes the merge while keeping history honest:
git log --oneline
git revert -m 1 a1b2c3d
Find the merge commit's identifier with git log --oneline, then revert it. The -m 1 flag tells Git to keep the first parent — the branch you merged into — and undo everything the merge brought in. Teammates who pull this new commit end up with the merge safely cancelled.
17. How real teams organise the flow
On professional projects, the branch-and-pull-request flow is usually reinforced by a few GitHub features you should recognise on sight:
- Protected branches: the repository settings can block direct pushes to
main. The only way in is a pull request, often with at least one required approval.
- Status checks: automated checks run on every pull request — for example building the project or running tests. Until they pass, the merge button stays locked.
- Pull request templates: many repositories include a template file, so every new PR description starts with ready-made sections such as "What", "Why" and "How to test".
- Linking issues: writing
Fixes #12 in the description connects the PR to issue number 12 and automatically closes that issue when the PR merges.
- Short-lived branches: feature branches live for days, not months. Long branches drift, conflict, and rot.
18. Common mistakes and the correct way
| Mistake | Why it is a problem | Correct way |
| Merging while you have uncommitted changes | The merge can fail or mix unfinished work into the result | Commit or stash your changes first, then merge |
| Merging into the wrong branch | Work lands somewhere unexpected | Run git branch and confirm the current branch before merging; if you already merged locally by mistake, git reset --hard ORIG_HEAD before pushing |
| Committing files that still contain conflict markers | Broken markup like <<<<<<< ships to everyone | Search the project for the marker lines before committing; editors usually highlight them |
| Resolving a conflict by blindly keeping one side | The other person's fix silently disappears | Read both versions, blend them if both are needed, and ask the other author when unsure |
| Giant pull requests mixing many unrelated changes | Reviewers get lost, bugs hide, conflicts multiply | One logical change per PR; split big work into a chain of small PRs |
Never updating the branch from main | Conflicts pile up until the final merge is painful | Merge origin/main into your branch regularly |
| Deleting a branch before its work is merged | The commits become hard to reach | Merge first; use git branch -d, which refuses to delete unmerged branches, rather than git branch -D |
| Vague PR titles like "update" or "fixes" | Reviewers cannot judge the change, and history becomes unreadable | Write what changed, why, and how to test it |
19. Best practices for merging and pull requests
- Start from fresh code: run
git switch main and git pull before creating any new feature branch.
- Keep pull requests small: a PR that changes a few files gets reviewed in minutes; a thousand-line PR gets ignored.
- Review your own diff before opening the PR: you will spot leftover debug lines and stray files immediately.
- Write descriptions for a busy reader: what changed, why, and the exact steps to test it.
- Integrate often: merging
main into your branch daily keeps conflicts tiny.
- Respond to every review comment, even if only to explain why you disagree — silence stalls the PR.
- Delete merged branches locally and on GitHub so the branch list shows only live work.
- Use draft pull requests when you want early feedback on unfinished work.
- Test after every merge: run the project and click through the affected pages before pushing.
- Never force-push shared branches; undo shared damage with
git revert instead.
20. Practical project: run a full team flow on your own
You can rehearse the entire professional workflow solo by playing the role of two developers. This small recipe website deliberately produces a fast-forward merge, a conflict, and a pull request.
Set up the base project
git clone https://github.com/your-username/recipe-site.git
cd recipe-site
git switch main
Create index.html with a simple navigation:
<h1>My Recipe Site</h1>
<nav>
<a href="index.html">Home</a>
</nav>
git add index.html
git commit -m "Add home page with navigation"
git push
Developer one: the salad page
git switch -c feature/salad-page
Add a Salad link to the <nav> in index.html, create a small salad.html, then commit. Do not merge yet — leave the branch parked.
git add index.html salad.html
git commit -m "Add salad page and nav link"
Developer two: the soup page
git switch main
git switch -c feature/soup-page
Edit the same nav line in index.html, this time adding a Soup link, create soup.html, and commit. Both branches now contain a different edit to the same line — a conflict is waiting.
Merge the salad branch locally
git switch main
git merge feature/salad-page
Because main has not moved, this is a clean fast-forward. Notice the word Fast-forward in the output.
Open a pull request for the soup branch
git push -u origin feature/soup-page
On GitHub, click Compare & pull request. GitHub reports that the branch has conflicts with main, because both changed the nav line — and the merge button is disabled. This is exactly what happens on real teams.
Resolve the conflict on the branch
git fetch origin
git merge origin/main
Open index.html and find the markers. Keep both links, removing all marker lines:
<nav>
<a href="index.html">Home</a>
<a href="salad.html">Salad</a>
<a href="soup.html">Soup</a>
</nav>
git add index.html
git commit -m "Merge main into feature/soup-page, keep both nav links"
git push
Merge the pull request and clean up
The PR is now conflict-free. Merge it using Squash and merge, then click Delete branch. Finish locally:
git switch main
git pull
git branch -d feature/salad-page
git branch -d feature/soup-page
git log --graph --oneline
You have now personally performed every role: two feature authors, a conflict resolver, a PR opener, and the person who merges. The graph at the end shows the whole story.
21. Practice Exercises
- Create a branch, add one commit to it, and merge it back with a fast-forward. Confirm with
git log --oneline that no merge commit exists.
- Create two branches that both change the
body background in styles.css. Merge one, then the other, resolve the conflict by keeping one colour, and add a comment in the CSS explaining the choice.
- Make a "noisy" branch with five tiny commits such as "typo", "again", "fix". Merge it with
git merge --squash, commit once with a meaningful message, and compare the history with a normal merge.
- Push a work-in-progress branch and open it as a draft pull request. Push one more commit, watch the PR update itself, then mark it ready for review.
- Pair up with a classmate: open a pull request in their repository and theirs in yours. Leave at least three specific line comments and one approval each.
- While your feature branch is open, merge something new into
main from a second clone, then update your branch with git fetch origin and git merge origin/main.
- Merge a branch, then undo it with
git revert -m 1. Verify the change is gone and that history still shows both the merge and the revert.
- After all exercises, run
git log --graph --oneline --all and sketch the commit graph on paper, labelling the fast-forward, the merge commit, and the conflict resolution.
22. Interview Questions and Answers
What is a merge conflict and how do you resolve it?
A merge conflict happens when two branches change the same lines of the same file, so Git cannot decide which version to keep. Git stops the merge, writes marker lines into the file, and waits. To resolve it, you open the file, edit the marked section to the final content you want, remove all the marker lines, stage the file with git add, and complete the merge with git commit.
Explain the difference between a fast-forward merge and a three-way merge.
A fast-forward merge is possible when the target branch has no new commits since the branch point: Git simply moves the branch pointer forward and no merge commit is created. A three-way merge is needed when both branches have new commits: Git combines the two lines of work and records a merge commit with two parents.
What is the difference between git merge and git pull?
git merge combines a named branch into your current branch using only what you already have locally. git pull is a combination command: it first fetches new work from the remote repository, then merges it into your current branch. So a pull is "download and merge", while a merge alone works with branches you already have.
What is a pull request and why do teams use them instead of merging directly?
A pull request is a proposal on GitHub to merge one branch into another, together with a page for discussion, line-by-line review, and approval. Teams use them because they add a quality gate: other eyes catch bugs, knowledge spreads across the team, automated checks must pass, and the conversation is recorded permanently. On projects with a protected main, a pull request is the only allowed way in.
What does git merge --no-ff do, and why might a team want it?
It forces Git to create a merge commit even when a fast-forward would be possible. Teams use it so that every feature remains visible as a grouped unit in history — the merge commit documents that a branch existed and was integrated as one piece.
What is a squash merge and when is it useful?
A squash merge compresses all of a branch's commits into one single new commit on the base branch. It is useful when a branch contains many small "work in progress" commits that would clutter history; the base branch then shows one clean commit per pull request.
What is the difference between merging and rebasing?
Merging combines two branches and creates a merge commit, preserving history exactly as it happened. Rebasing replays your branch's commits on top of the target branch, producing a straight line of history but rewriting the original commits. The safety rule: rebase only your own unshared branches, because rewriting commits that others already have causes duplicate work.
A merge was already pushed and it broke the site. How do you undo it?
You do not rewrite the shared history. You find the merge commit's identifier with git log --oneline and run git revert -m 1 <commit-id>. This creates a new commit that undoes everything the merge introduced, keeping the first parent — the branch you merged into. Everyone then pulls this corrective commit.
What do the conflict markers in a file mean?
The line <<<<<<< HEAD starts your current branch's version, the line ======= divides the two versions, and the marker ending with the branch name closes the incoming version. Everything between the outer markers is Git showing you both sides side by side; your job is to replace the whole block with the correct final content.
What is a protected branch?
A protected branch, usually main, has rules in the repository settings that block direct pushes. Changes must arrive through pull requests, often with required approvals and passing automated checks. This prevents accidental or unreviewed changes from reaching the shared code.
How do you keep a long-running feature branch healthy?
By integrating often: regularly fetch and merge origin/main into the feature branch, resolving small conflicts immediately; push frequently so the pull request stays current; and keep the branch focused on one change so it can be merged soon rather than living for weeks.
What is the difference between git branch -d and git branch -D?
git branch -d deletes a branch only if its commits have been merged, so it is the safe choice. git branch -D forces deletion even when the work is unmerged, which can make those commits hard to reach — use it only when you are certain the work is no longer needed.
23. Quick Revision Checklist
- Merging always happens into the current branch — switch to the target first.
- Fast-forward = target had no new commits; three-way merge = both branches advanced, producing a merge commit with two parents.
- Conflict markers: your version after
<<<<<<< HEAD, theirs before the branch-name marker; resolve by editing, removing markers, git add, git commit.
- Escape hatches:
git merge --abort during a conflict, git reset --hard ORIG_HEAD for an unpushed local merge, git revert -m 1 for a pushed one.
- Pull request cycle:
git push -u origin branch, open PR, review, approve, merge, delete branch, git pull locally.
- GitHub merge methods: merge commit (full history), squash (one commit per PR), rebase (linear history).
- Keep feature branches updated by merging
origin/main into them regularly.
- Small, focused pull requests with clear descriptions get reviewed faster.
git branch -d is the safe delete; -D forces.
Fixes #12 in a PR description links and closes issue 12 on merge.
- Never force-push shared branches; repair shared history with revert.
- Protected
main means the pull request is the only door in.
Conclusion
Merging and pull requests are the moment where all the earlier Git skills — repositories, commits, and branches — turn into real teamwork. Merging is the mechanical act of combining two lines of work, and Git supports it with clear tools for every situation: fast-forwards for simple cases, merge commits for parallel work, conflict markers for honest human decisions, and revert for safe repairs. Pull requests wrap that mechanism in the social layer that professional teams depend on: review, discussion, automated checks, and a permanent record of why every change was made.
The workflow you practised here — branch, commit, push, open a pull request, review, resolve conflicts, merge, clean up — is the same workflow used to build large React applications, where each component or feature typically lands through its own reviewed pull request. In the next sub-module on team workflow, you will see how these pieces are arranged into an everyday routine for a whole team, including how to divide work, agree on branch names, and keep a project moving without stepping on each other's code.
Learn more in the React JS Training course, or register for a course demo.