Git & GitHub·Collaboration

Branches, remotes and PRs

Isolate work, push it safely and merge through review.

Beginner 15 min read Lesson 7 of 480 Challenge included
What you will be able to do
  • Create and switch branches
  • Push to a remote
  • Open a pull request and resolve conflicts

A branch is a movable pointer to a commit. Feature branches let you experiment without disturbing main. Pull requests add review and discussion.

terminalTerminal
git switch -c feature/pricing
# make changes
git add .
git commit -m "Add pricing comparison table"

git push -u origin feature/pricing

# after review and merge
git switch main
git pull
git branch -d feature/pricing

Resolving a conflict

A conflict happens when two branches change the same lines. Git marks the overlap; you choose the final content, remove the markers, then commit.

conflict.jsText
<<<<<<< HEAD
const price = 19;
=======
const price = 24;
>>>>>>> feature/pricing
Your turn

Start a feature

Medium

Create and switch to a branch called feature/search, then push it with an upstream.

BASH · starter
# your commands here
Check your understanding before moving on.
Knowledge checkQuestion 1

What does git push -u origin feature/pricing do?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Undoing changes
Lesson 7 of 480 · 0% of course