Team workflow in React JS
Course: React JS Training
Topic: Team workflow
Course Link: React JS Training
Demo Link: Register for a Course Demo
1. Why teams need a shared workflow
Working alone, Git can stay simple: you edit files, you commit, you push straight to main. The moment a second person commits to the same repository, that habit starts to break things. One teammate pushes a half-finished page, another pushes a fix that overwrites it, and the shared branch stops working for everyone.
A workflow is the answer. Git already gives you branches, remotes and merges; a team workflow is the agreed way your team uses those tools so that several people can work at the same time without stepping on each other.
What goes wrong without one
- A broken shared branch. If everyone commits straight to
main, one careless commit can leave the whole team with a page that does not open.
- Overwritten work. Two people editing the same file on
main fight with each other's commits instead of working side by side.
- Unreviewable changes. A month of work arrives as one giant commit nobody can realistically read, so mistakes ship silently.
- Mystery conflicts. Branches live for weeks, drift far from
main, and every merge becomes painful.
With a shared workflow, each change lives on its own small branch, is proposed through a pull request, gets read by a teammate, and only then joins main. The rest of this page walks through that path in detail.
2. What a team workflow means in simple words
Think of the repository on GitHub as the team's shared cupboard. A workflow is the house rule for touching it: never edit the cupboard directly — take a copy, work on the copy, show the change, and put it back only after someone checks it.
One-line definition: a team workflow is the repeatable path every change follows — branch, commit, push, pull request, review, merge, then sync — so that main always stays usable for everybody.
It helps to separate the three layers involved:
- Git is the tool that records history and merges changes.
- GitHub is the shared home for the repository, where teammates see branches, pull requests and comments.
- The workflow is the habit the team agrees on — who branches from where, when code is reviewed, and how changes land.
Git does not force any of these habits on you. Two teams using exactly the same Git commands can run completely different workflows, which is why "how does your team work?" is always worth asking when you join a project.
3. Key terms of the team workflow
These are the words you will hear in every planning call and code review. Learn them once and every later section becomes easier to read.
| Term | Plain meaning |
repository | The project's folder plus its full history; the shared copy lives on GitHub. |
remote / origin | A named address for the shared repository; origin is the default name for the GitHub copy. |
clone | Download the repository to your machine, including its history. |
main | The shared branch the team treats as the always-working version. |
| feature branch | A short-lived branch where exactly one task is built. |
commit | A saved snapshot of your change, with a message explaining it. |
push / pull | Upload your commits to GitHub, or download your teammates' commits. |
| pull request (PR) | A proposal page: "here is my branch, please consider merging it into main". |
| code review | Teammates read the PR's diff and comment, approve it, or request changes. |
| merge | Combining one branch's commits into another, usually a feature branch into main. |
| merge conflict | Git's signal that two changes touch the same lines and a human must decide. |
rebase | Moving your commits on top of another branch to keep history straight. |
4. Branch structure that keeps the team organized
Most web teams run on one simple rule: main is the truth, and every change starts from it and returns to it.
main always works — anyone should be able to pull it and get a running site.
- Every task gets its own branch, created from the latest
main, with a name that says what it does.
- Branches are short-lived, ideally merged within days, so they never drift far from the truth.
A healthy branch list looks like this:
main
feature/contact-form
fix/navbar-overlap
docs/update-readme
| Branch type | Name style | Purpose | Typical lifetime |
main | main | The shared, working version of the site | Permanent |
| Feature | feature/contact-form | Builds one new thing, such as a section or a page | Days |
| Fix | fix/navbar-overlap | Repairs one bug | Days |
| Docs | docs/update-readme | Improves documentation only | Hours to days |
Larger teams sometimes add a long-lived develop branch where finished features gather before a release. For a course project or a small team, plain main plus short feature branches is enough — extra structure only pays off when the team and the release cycle are bigger.
5. The feature branch workflow step by step
Here is the complete loop that every change follows. The later sections show each step with real commands and output.
- Sync first. Switch to
main and pull, so your new branch starts from the latest shared code.
- Branch. Create one branch for one task, with a descriptive name.
- Build and commit small. Work on the task and commit each finished piece with a clear message.
- Push the branch. Upload it to GitHub so teammates can see it and your work is never lost.
- Open a pull request. Describe what changed, why, and how to test it.
- Review. Teammates read the diff and comment, approve, or request changes; you reply and push fixes to the same branch.
- Stay current. If
main moved ahead, fold its new commits into your branch and fix conflicts early.
- Merge. Once approved, the branch joins
main using the merge style your team chose.
- Clean up and sync. Delete the branch on GitHub, pull
main locally, and start the next task.
git switch main
git pull origin main
git switch -c feature/search-bar
# edit files, then commit small pieces
git add index.html
git commit -m "Add search bar to the header"
git push -u origin feature/search-bar
# the pull request, review and merge happen on GitHub
git switch main
git pull origin main
git branch -d feature/search-bar
Lines starting with # are notes to you, not commands: they mark what happens on GitHub between the pushes.
6. Worked example: your first feature branch
Suppose your team's repository is a small portfolio site, and your task is to add a contact section to the home page. Starting from nothing:
git clone https://github.com/team-site/portfolio.git
cd portfolio
git switch -c feature/contact-section
You now edit index.html and add the new section:
<section id="contact">
<h2>Contact us</h2>
<p>Email us at [email protected]</p>
</section>
Checking what changed before committing is a habit worth building:
git status
On branch feature/contact-section
Changes not staged for commit:
modified: index.html
Stage and commit the change, then push the branch:
git add index.html
git commit -m "Add contact section to the home page"
[feature/contact-section 4f2c1a9] Add contact section to the home page
1 file changed, 4 insertions(+)
git push -u origin feature/contact-section
* [new branch] feature/contact-section -> feature/contact-section
The -u flag links your local branch to its GitHub copy, so every later push on this branch only needs git push. GitHub now offers a link to open the pull request for this branch — the next step in the workflow.
7. Worked example: staying current with the shared branch
Your branch is not the only thing moving. While you build, teammates merge their work into main, and the longer you ignore that, the harder the eventual merge becomes. The fix is to fold new main work into your branch before the final review.
git switch feature/contact-section
git fetch origin
git merge origin/main
git fetch downloads the newest commits from GitHub without touching your files; merging origin/main then brings those commits into your branch. Teams that prefer a straight-line history use git rebase origin/main for the same goal:
| Command | What it does | Resulting history | Watch out for |
git merge origin/main | Adds a merge commit tying both histories together | Honest but wavy: extra merge commits appear | Nothing serious; the safe default |
git rebase origin/main | Replays your commits on top of the latest main | A straight line, no merge commits | Rewrites your commits; never rebase a branch others build on |
After merging, your history shows both streams:
git log --oneline --graph --max-count 4
* a9c3f1e Merge branch 'main' into feature/contact-section
|\
| * 77bd201 Fix navbar overlap on small screens
* | 4f2c1a9 Add contact section to the home page
|/
Both approaches are correct; the rule that matters is consistency. Whatever the team picks, apply it the same way every time, and never rewrite commits that other people already have.
8. Worked example: the pull request and code review
The pull request is where the workflow becomes visible to the whole team. A good PR lets a reviewer understand the change in under a minute.
Writing the pull request
Keep the title in the same style as your commits, and fill in a short description:
Title: Add contact section to the home page
What this change does
- Adds a contact section below the hero on index.html
- Uses the existing site colours, no new styles
How to test it
- Open index.html in the browser
- Check the section at phone width
Notes
- Does not touch the navbar or the footer
Reading review comments
Reviewers usually mark how strongly they feel, so you know what must change and what is only a suggestion:
blocker: a real problem that must be fixed before merging, such as a broken layout.
question: the reviewer wants to understand a choice, not force a change.
nit: a small preference, such as naming or spacing; fix it if it is quick.
You respond by replying to comments and pushing more commits to the same branch — the PR updates automatically, and no new PR is needed. Once a teammate approves, the PR is ready to merge.
Choosing a merge style
| Merge style on GitHub | What lands on main | Best when |
| Merge commit | Your commits plus one merge commit | The team wants every commit preserved |
| Squash and merge | One tidy commit for the whole branch | The branch has many small "fix typo" commits |
| Rebase and merge | Your commits replayed, no merge commit | The team prefers a straight-line history |
Small teams most often pick one of the first two and stay with it. What matters is that everyone knows the choice, so the history stays predictable.
9. Resolving merge conflicts together
A conflict happens when two branches change the same lines and Git cannot choose for you. It is a normal part of teamwork, not an error. Suppose you and a teammate both rewrite the same heading — your branch says one thing, main says another. Starting the merge shows:
git merge origin/main
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
Opening index.html reveals Git's markers:
<h1>
<<<<<<< HEAD
Welcome to our studio
=======
Welcome to our portfolio
>>>>>>> main
</h1>
The lines between <<<<<<< HEAD and ======= are your version; the lines below are the incoming ones. You edit the file to the final text — here, keeping the teammate's wording and adding your idea:
<h1>
Welcome to our studio and portfolio
</h1>
Then you finish the merge:
git add index.html
git commit
If the conflict appears during a git rebase, you resolve the file the same way and run git rebase --continue instead. To keep conflicts rare and small:
- Keep branches small and short-lived; a two-day branch rarely conflicts badly.
- Sync with
main often, not only before the final review.
- Talk before starting a big refactor that touches shared files.
- Split shared files, such as one CSS file per page, so teammates edit different regions.
10. Commit messages and branch naming conventions
In a team, messages are how everyone reads history. A commit message has a subject line and, when needed, a body that explains why the change was made.
| Weak subject | Clear subject | Why it is better |
update | Add contact section to the home page | Says what changed and where |
fix bug | Fix navbar overlap on small screens | Names the actual problem |
final changes | Center the footer text | Still meaningful a year later |
Many teams add a short prefix that sorts the history by type:
git log --oneline
4f2c1a9 feat: add contact section to the home page
77bd201 fix: keep navbar above the hero on small screens
2b10e44 docs: list the setup steps in the readme
Branch names follow the same spirit: a type, a slash, and a few lowercase words with hyphens, such as feature/search-bar or fix/footer-spacing. Avoid personal names and vague words like my-changes — the branch name should tell a teammate what they will find inside. Agree on these conventions once, write them in the repository's readme, and let every new commit follow the pattern.
11. Comparing common team workflows
There is no single official workflow, but most teams use one of three patterns. Knowing the trade-offs helps you fit into any team quickly.
| Workflow | How it works | Fits best | Main risk |
| Centralized | Everyone commits and pushes straight to main | Very small teams, throwaway prototypes | One broken commit breaks the branch for all |
| Feature branch | Each task gets a branch and a pull request into main | Most teams, including small web teams | Changes land slower because of reviews |
| Forking | Contributors copy the repository, push to their copy, and open PRs from it | Open-source projects with outside contributors | Keeping the copy in sync takes discipline |
For a course project or a small agency team, the feature branch workflow is the sensible default: it is simple, it keeps main safe, and it builds the review habit that bigger teams expect. The forking workflow appears when contributors do not have write access to the main repository — but the daily habit remains the same: small branch, clear commits, reviewed pull request.
12. Safety nets and shared habits
The workflow only works when the team also agrees on a few protective habits:
- Protect
main. On GitHub, branch protection can require a review and block direct pushes, so main only changes through merged pull requests.
- Never force-push shared branches. Rewriting
main or a teammate's branch erases other people's commits; rewriting is only safe on your own feature branch.
- Keep pull requests small. A PR of a few files gets a real review; a PR of fifty files gets a click of approval and hidden mistakes.
- Pull every day. Starting the morning with
git pull origin main prevents week-long drift.
- Ignore what should not be shared. Put build folders and local settings in
.gitignore, and never commit passwords or keys.
- Communicate around conflicts. A quick message before a big change to a shared file saves everyone a merge headache.
13. A realistic end-to-end team scenario
Priya and Arjun share a small portfolio repository. Priya picks the contact section; Arjun picks the footer. They follow the same loop:
- Both switch to
main, pull, and create feature/contact-section and feature/footer-links.
- Priya finishes first: she pushes, opens a pull request, and Arjun approves it after reading the diff. The PR merges with a squash commit.
- Arjun finishes an hour later. Before his final review, he merges
origin/main into his branch and gets a one-line conflict in index.html, because the contact section and the footer touch the same area. He resolves it in a minute and pushes.
- His PR is approved and merged. Both delete their branches, pull
main, and the site shows both features with a readable history:
git log --oneline
c8e4f02 feat: add footer links and social icons
7a1b3d5 Merge pull request from arjun/feature/footer-links
4f2c1a9 feat: add contact section to the home page
b71e0d3 Initial commit
Nothing in that story needed advanced Git — only the agreed path: sync, branch, commit, push, propose, review, merge, and sync again. That path, repeated for every task, is the team workflow.
14. Real-world team habits: draft PRs, hotfixes and linking commits
Once the basic loop — branch, commit, pull request, review, merge — becomes second nature, teams add a few habits that make day-to-day work smoother. Three of the most useful are draft pull requests, hotfix branches and linking work to issues.
Draft pull requests
Sometimes you want to share progress before the work is ready for a real review. GitHub lets you open a pull request as a draft. Teammates can see what you are building and comment early, but the PR is clearly marked as not finished, so nobody merges it by accident. When the work is complete, you mark it "Ready for review" and the normal process begins.
Hotfix branches
An urgent bug — a broken link, a crashed page — cannot wait for your current feature to finish. The team habit is a short-lived hotfix/ branch created straight from the latest main:
git switch main
git pull origin main
git switch -c hotfix/signup-link
# fix the bug, then commit it
git add signup.html
git commit -m "fix: point the signup button to the new page"
git push -u origin hotfix/signup-link
The PR gets an urgent review, merges quickly, and main is healthy again. Your half-finished feature branch simply picks up the fix the next time you merge origin/main into it — the same "stay current" step from the basic workflow.
Linking commits and pull requests to issues
Teams usually track tasks as issues on GitHub. Writing the issue number in a commit or PR description ties the work together, and certain keywords do even more: writing Fixes #12 in the PR description makes GitHub close issue 12 automatically when the PR merges.
Title: Fix signup link
Fixes #12
The signup button still pointed at the old page.
Updated the href and tested the flow end to end.
Even without the keyword, a reference like #12 becomes a clickable link, so anyone reading the history can jump from the change to the task and back.
15. How to review a teammate's pull request
Reviewing well is half of the team workflow. A good review protects main, spreads knowledge of the code across the team, and helps the author improve — without turning into criticism of the person.
The reviewer's routine
- Read the description first. Understand what the change claims to do before looking at any code.
- Read the diff file by file. GitHub shows every added and removed line; look for logic errors, leftover debug code and naming problems.
- Run it when it matters. For bigger changes, fetch the branch and test it yourself:
git fetch origin
git switch feature/footer-links
# open the project in the browser and try the change
- Leave comments with clear weight. Say whether something must change or is only a suggestion.
- Finish with a clear verdict. Approve, request changes, or comment — never leave the author guessing.
What a good review comment looks like
blocker: this button has no accessible label, so screen readers will just say "button". Could we add one?
question: why a new CSS file here instead of the shared stylesheet?
nit: "recieve" is misspelled in the placeholder text.
Notice the tone: the comments point at the code, not the author, and the question asks for reasoning instead of ordering a change. That keeps reviews fast, friendly and useful — the author knows exactly what is mandatory and what is optional.
16. Contributing through a fork
The feature branch workflow assumes you can push branches to the shared repository. That works inside a company or a course team, but on open-source projects you usually have no write access. The forking workflow solves this: you work in your own copy of the repository and propose changes from there.
The fork workflow step by step
- Fork the project on GitHub. This creates
your-name/project, a copy you own.
- Clone your fork, not the original:
git clone https://github.com/your-name/project.git
cd project
# connect the original repository as a second remote
git remote add upstream https://github.com/original-owner/project.git
Now origin points at your fork, where you may push, and upstream points at the real project, where you only read.
- Branch from the upstream's latest state and build your change:
git fetch upstream
git switch -c feature/dark-mode-toggle upstream/main
# make your change, then commit it
git push -u origin feature/dark-mode-toggle
- Open the pull request from your fork's branch to the original project's
main. The maintainers review and merge it exactly as an internal team would.
Keeping your fork in sync
Your fork does not update itself. Regularly pull the original project into your local copy and push it back to your fork:
git switch main
git fetch upstream
git merge upstream/main
git push origin main
| Situation | Where you push branches | Who reviews |
| Team member on a shared repository | The shared repository itself | Teammates with write access |
| Outside contributor via fork | Your own fork on GitHub | The project's maintainers |
The daily habit is identical in both cases — small branch, clear commits, reviewed pull request — only the destination of your pushes differs.
17. Handling interruptions with stash and WIP commits
Team life is full of interruptions: an urgent review request, a quick question, a bug that must be looked at now. You cannot always finish your current change before switching tasks, and Git gives you two clean ways to park it.
Parking unfinished work with stash
git stash sweeps your uncommitted changes into a safe shelf, leaving the working tree clean so you can switch branches:
git stash
Saved working directory and index state WIP on feature/search-bar: 4f2c1a9 Add search bar to the header
After helping with the urgent task, come back and restore everything:
git stash pop
Your half-written files return exactly as you left them. Useful stash commands:
git stash list — show everything on the shelf.
git stash apply stash@{1} — restore a specific older stash while keeping it on the list.
git stash pop — restore the newest stash and remove it from the list.
Remember that a stash lives only on your machine — it is never pushed, so it is for interruptions measured in hours, not for sharing work.
WIP commits and amending
For interruptions that last overnight, some developers commit the unfinished state with an honest message such as wip: halfway through the search filter. The work is then safely recorded and pushable to your own branch. When you finish later, you can fold the finishing touches into the same commit — as long as you have not shared it for review yet:
git add search.js
git commit --amend -m "feat: add a working search filter"
--amend replaces the last commit with a new one. That is history rewriting, so the rule from earlier applies: amend freely on your own unpushed or unreviewed branch, never on main or a branch a teammate is building on.
18. Common mistakes and the correct way
Almost every team-workflow problem traces back to a handful of repeated mistakes. Learning to recognise them early saves hours of repair work.
| Mistake | Why it hurts | The correct way |
Committing straight to main | One bad commit breaks the branch for the whole team | Branch for every task, land changes through a PR |
| Pushing without pulling first | Push is rejected, or you build on stale code | Pull at the start of every work session |
Committing secrets or node_modules | Leaked keys, a bloated repository that is hard to clean | List them in .gitignore before the first commit |
| One giant "everything" commit | Impossible to review or to revert sensibly | One commit per logical change |
| Force-pushing a shared branch | Erases commits your teammates already have | Never rewrite shared history; rewrite only your own branch |
| Resolving a conflict by blindly keeping your side | Silently deletes the teammate's work | Read both versions, merge the intent, test the result |
Vague messages like update | History becomes unreadable | Subjects that say what changed and where |
| Opening a 40-file pull request | Reviewers skim and approve without reading | Split the work into small, focused PRs |
| Mixing formatting changes with logic changes | The real change hides inside reformatting noise | Separate commits, or a separate PR, for formatting |
| Keeping merged branches forever | Clutter and confusion about what is still active | Delete the branch after the PR merges |
Two of these deserve extra emphasis. Force-pushing (git push --force) overwrites the remote branch with your local version; on a shared branch that deletes other people's work, which is why protection rules and team etiquette forbid it there. Blind conflict resolution is dangerous because Git's markers make it easy to just delete one side — but the conflict exists precisely because both sides matter, so the resolution deserves a real decision and a quick test afterwards.
19. Best practices for a smooth team workflow
The following habits separate teams where merges are boring from teams where merges are feared:
- Sync little and often. Pull
main every morning and merge it into active branches every day or two; small conflicts are routine, week-long drift is painful.
- One branch, one task. If a branch name needs the word "and", it is probably two branches.
- Commit small, describe clearly. Each commit should make sense on its own, with a subject that survives a year.
- Push at the end of every session. Unpushed work is unprotected work.
- Open PRs early, small and with a test plan. The description should let any teammate verify the change.
- Review promptly and kindly. A PR waiting two days loses momentum; a harsh review loses trust.
- Agree on conventions once, in writing. Branch naming, commit prefixes and merge style belong in the repository's readme, so newcomers follow the same path.
- Protect
main. Require reviews through branch protection so that no single push can break the shared branch.
- Never commit what can be regenerated or must stay secret. Build output and dependencies go to
.gitignore; keys and passwords stay out entirely.
- Talk before big refactors. A two-minute message about "I am renaming the shared CSS file today" prevents a week of conflicts.
20. Practical project: run a complete team workflow by yourself
You do not need a partner to practise the team workflow. By cloning the same repository into two folders, you can play both roles — one folder is "you", the other is your "teammate" — and experience a real merge conflict from both sides.
Setup: the shared repository
- On GitHub, create a new repository named
team-site, tick "Add a README", and create the repository.
- On GitHub, use Add file → Create new file to add
index.html to main with this content, then commit it:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Team Site</title>
</head>
<body>
<h1>Welcome</h1>
</body>
</html>
- Clone the repository twice, into two folders that play the two roles:
git clone https://github.com/your-name/team-site.git work
git clone https://github.com/your-name/team-site.git teammate
Phase 1: the teammate ships first
In the teammate folder, build and ship a small change:
cd teammate
git switch -c feature/headline
Edit index.html so the heading line reads <h1>Welcome to Team Site</h1>, then:
git add index.html
git commit -m "feat: clarify the headline"
git push -u origin feature/headline
On GitHub, open the pull request, read the diff as a reviewer would, merge it with Squash and merge, and delete the branch. main has moved — your other folder does not know yet.
Phase 2: you build a conflicting change
In the work folder, start a change to the same line — deliberately, so a conflict occurs:
cd ../work
git switch -c feature/headline-style
Change the heading to <h1>Welcome to our studio</h1>, then commit and push:
git add index.html
git commit -m "feat: give the headline a studio voice"
git push -u origin feature/headline-style
Open the pull request. GitHub reports that this branch has conflicts with main — exactly what happens in real teams.
Phase 3: resolve the conflict and merge
git fetch origin
git merge origin/main
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 find the markers:
<h1>
<<<<<<< HEAD
Welcome to our studio
=======
Welcome to Team Site
>>>>>>> main
</h1>
Decide the final wording — here, keep your version — remove the markers, and finish:
<h1>Welcome to our studio</h1>
git add index.html
git commit
git push
The pull request updates automatically and the conflict badge disappears. Merge it, and delete the branch.
Phase 4: clean up and verify
Back in the teammate folder, sync and tidy up:
git switch main
git pull origin main
git branch -d feature/headline
Confirm the shared history and the final file:
git log --oneline
9d4e1c7 feat: give the headline a studio voice
6b8f2a3 feat: clarify the headline
1a2c3d4 Initial commit
You have now personally played both sides of the workflow: author, reviewer, merger, and conflict resolver. Repeat this drill until the commands feel automatic — it is the same loop you will use on every team project, including React codebases where several people touch components in parallel.
21. Practice Exercises
- Conflict drill. Repeat the practical project, but this time resolve the conflict in favour of your "teammate's" wording instead of your own, and write a merge commit message explaining the choice.
- Squash by hand. On a new branch, make three messy commits (
start, wip, still wip). Before pushing, run git rebase -i main and squash them into one clear commit. Verify with git log --oneline.
- Stash drill. Start editing a file, run
git stash, switch to main to "fix an urgent bug" (change one word and commit), return to your branch, and git stash pop. Confirm your unfinished edit is back.
- Message gym. For these three scenarios, write subject lines under 50 characters: fixing a typo in the footer, adding a photo gallery page, upgrading the CSS grid layout of the pricing table. Then compare with a classmate's versions.
- Fork practice. Fork any public repository you like, clone your fork, add the
upstream remote, and sync main from upstream. Confirm with git remote -v that both remotes are set.
- Draft PR drill. Push a branch with an unfinished change, open it as a draft PR with a short description, then mark it ready for review once you "finish" the work.
- Review drill. Exchange a pull request with a classmate. Each of you must leave one
blocker, one question and one nit comment, then respond to them and merge.
- Branch audit. Find a badly named branch in a practice repository (for example
my-stuff) and rename it locally with git branch -m my-stuff fix/footer-spacing. Note what you would need to do if it had already been pushed.
22. Interview Questions and Answers
Why do teams use feature branches instead of committing straight to main?
Because main must stay usable for everyone at all times. A feature branch isolates unfinished or risky work so a mistake affects only one person, and the pull request gives the team a chance to review the change before it becomes everyone's problem. Direct commits to main remove both safety nets.
What is a pull request, and what happens during a review?
A pull request is a proposal to merge one branch into another, shown on GitHub as a page with the full diff, a description and a discussion thread. During review, teammates read the diff, run the change if needed, and leave comments; the author pushes fixes to the same branch until a reviewer approves and the PR is merged.
How do you resolve a merge conflict?
You open the conflicted files, find the <<<<<<<, ======= and >>>>>>> markers, decide what the final content should be by understanding both versions rather than blindly keeping one side, remove the markers, stage the files with git add, and complete the merge with a commit — or continue the rebase if the conflict arose during one. Testing the result before pushing is essential.
What is the difference between merge and rebase in a team setting?
Merge combines two histories and records a merge commit, preserving the branch's real shape. Rebase replays your commits on top of another branch, producing a straight-line history but rewriting your commits. In a team, merging is always safe, while rebasing is only safe on branches nobody else has pulled — rebasing a shared branch rewrites history that teammates already have.
What is squash merging and when would you choose it?
Squash merging condenses every commit on the feature branch into a single commit on main. It is a good choice when the branch accumulated many small "fix typo" commits that would clutter the shared history, and you prefer main to show one clean, meaningful commit per change.
What is branch protection and why does it matter?
Branch protection is a GitHub setting that restricts what can happen to a branch such as main — for example, blocking direct pushes and requiring an approving review before a merge. It turns the team's agreed discipline into something the platform enforces, so main cannot be broken by a single accidental push.
How do you keep a long-running branch healthy?
By merging origin/main into it regularly — daily or every couple of days — so conflicts stay small, and by keeping its scope as narrow as possible. If a branch grows for weeks, it is usually a sign it should have been split into several smaller branches and pull requests.
You accidentally committed a secret, such as an API key. What do you do?
First, treat the key as compromised: revoke or rotate it, because it may already have been pulled or cloned. Then remove the secret from the code and commit the removal. Deleting the file in a new commit does not erase it from history, so teams use history-rewriting tools for sensitive repositories — but rotating the credential is the step that actually makes you safe.
How does the forking workflow differ from the shared-repository workflow?
In the shared-repository workflow, teammates push branches directly to the one repository and open PRs inside it. In the forking workflow, used for open source, contributors without write access fork the project, push branches to their own copy, and open PRs from the fork to the original. The habits — small branches, clear commits, review before merge — are the same in both.
What makes a good pull request description?
It answers three questions quickly: what changed, why it changed, and how a reviewer can test it. A short list of the touched areas, a test plan, and links to related issues let a reviewer approve with confidence instead of guessing from the diff alone.
An urgent production bug appears while you are mid-feature. What is your process?
Park the unfinished work safely — git stash or a WIP commit on your feature branch — then switch to a fresh hotfix/ branch created from the latest main, fix the bug with a small commit, and land it through a fast-tracked PR. Afterwards, return to your feature branch and merge origin/main into it so it includes the fix.
A teammate force-pushed main and your local history no longer matches. What now?
First, stop and communicate — this should not happen on a protected branch, so the immediate step is coordinating with the team to agree which history is correct. Then fetch, compare the histories, and reset your local main to the agreed remote state after backing up any local commits you still need. The real answer interviewers look for is prevention: shared branches are never force-pushed, and protection rules make that a platform rule rather than a promise.
23. Quick Revision Checklist
- A team workflow is the agreed path every change follows: branch, commit, push, pull request, review, merge, sync.
main always works; every task gets its own short-lived branch named type/description.
- Pull at the start of each session; merge
origin/main into active branches regularly.
- One commit per logical change, with a subject that says what changed and where.
- A good PR is small, has a clear description with a test plan, and links its issue with keywords like
Fixes #12.
- Review comments carry weight:
blocker, question, nit; review the code, not the person.
- Merge styles: merge commit keeps everything, squash gives one tidy commit, rebase gives a straight line — pick one as a team.
- Conflicts are normal: read both sides, resolve deliberately, test, then commit.
- Never force-push or rewrite shared branches; amend and rebase only your own unshared work.
- Use
git stash for short interruptions and WIP commits for overnight ones.
- Hotfixes branch from
main, merge fast, and reach feature branches on their next sync.
- Forks are for contributing without write access:
origin is yours, upstream is the original.
- Keep secrets and generated folders out of commits with
.gitignore; rotate any key that ever lands in history.
Conclusion
The team workflow is where Git stops being a personal tool and becomes a collaboration system. The commands are the ones you already know — switch, commit, push, pull, merge — but the discipline around them is what keeps main healthy, reviews meaningful and conflicts small. Feature branches, clear messages, small pull requests and respectful reviews are habits, and habits are built by repetition, like the two-folder drill in this page.
As you move on to building React applications, this loop is the one you will repeat for every component, hook and page you build with others. Master it now, on small HTML and CSS projects, and joining your first real development team will feel like following a path you have already walked.
Learn more in the React JS Training course, or register for a course demo.