Git & GitHub ยท Chapter 36 of 42

Collaborating in Teams

Working with Git on a team means following shared conventions: consistent branch naming, small pull requests, regular pulls, and clear communication about who is working on what.

GitHub adds team features like repository permissions, protected branches (requiring reviews before merging), and notifications, all of which help teams collaborate smoothly without stepping on each other's work.

Syntax
git switch -c feature/your-name-task
# small commits, frequent pushes, open PR early

Branch protection

Protected branches (often main) can require passing checks and approved reviews before a pull request can be merged, preventing broken or unreviewed code from landing directly.

Team communication

Use clear PR descriptions, comment on issues, tag teammates with @username to notify them, and keep commits focused so reviewers can understand changes quickly.

Example 1 (bash)
git pull origin main
git switch -c feature/alex-search-bar
Output
Switched to a new branch 'feature/alex-search-bar'

Pulls the latest main first, then creates a clearly named feature branch to avoid conflicts with teammates.

Example 2 (bash)
git push -u origin feature/alex-search-bar
Output
Branch 'feature/alex-search-bar' set up to track remote branch.

Pushes the branch early so teammates can see work in progress and provide feedback sooner.

Key points

  • Teams benefit from shared conventions like branch naming and small PRs.
  • Protected branches require reviews or checks before merging.
  • Regularly pulling reduces the risk of large conflicts.
  • Clear communication in PRs and issues keeps teams aligned.
๐Ÿ’ก Note: Opening a pull request early, even as a 'draft', lets teammates give feedback before you've finished all the work.

๐Ÿ“ Quick Quiz

1. What does a protected branch require before merging?

2. Why should teams pull regularly?

3. What is a benefit of small, focused pull requests?