Computer Science
Grade 9
20 min
10. Chapter Project: Collaborative Coding Project with Git
Work on a collaborative coding project using Git to practice branching, merging, and resolving conflicts.
Tutorial Preview
1
Introduction & Learning Objectives
Learning Objectives
Initialize and clone a shared remote repository from a platform like GitHub.
Create, switch to, and work on a separate feature branch to isolate their changes.
Commit their work with clear, descriptive messages following a standard format.
Push their local branch to the remote repository to share their work with teammates.
Create a pull request to propose merging their changes into the main project branch.
Perform a basic code review on a teammate's pull request.
Identify and resolve a simple merge conflict.
Ever wondered how huge teams build video games or apps without accidentally deleting each other's work? 🎮 Let's learn the secret!
In this project, you'll team up to build a small application, just like a real software developme...
2
Key Concepts & Vocabulary
TermDefinitionExample
Remote RepositoryA version of your project hosted on the internet, typically on a service like GitHub. It acts as the central 'source of truth' that all team members share.The project your teacher creates on GitHub, which you and your teammates will all connect to.
CloningThe process of creating a complete, local copy of a remote repository on your own computer.Running the command `git clone https://github.com/your-team/our-project.git` in your terminal.
BranchA separate line of development within a repository. Branches let you work on a new feature or bug fix without affecting the main, stable version of the code.Creating a branch called `add-header-image` to work on the website's header without breaking the main `main` branch.
PushThe command to send...
3
Core Syntax & Patterns
The Standard Collaborative Workflow
1. Pull → 2. Branch → 3. Code & Commit → 4. Push → 5. Pull Request
This is the fundamental pattern for safe team collaboration. Always pull the latest changes, create a new branch for your task, do your work in small commits, push your branch, and then open a pull request for review. This prevents chaos in the main branch.
Writing Good Commit Messages
Use the imperative mood (e.g., 'Add user login feature'). Start with a capital letter. Keep the subject line short and descriptive.
Commit messages are a log of the project's history. Clear messages help your teammates (and your future self) understand what change was made and why, without having to read every line of code.
Resolving a Merge Conflict
1. Identify confl...
4 more steps in this tutorial
Sign up free to access the complete tutorial with worked examples and practice.
Sign Up Free to ContinueSample Practice Questions
Challenging
A new team member pushes a change directly to the `main` branch, which accidentally breaks the project for everyone. Which part of the 'Standard Collaborative Workflow' was skipped that is specifically designed to prevent this kind of error?
A.Creating a Pull Request and having a code review.
B.Cloning the repository to their local machine.
C.Committing their work with a descriptive message.
D.Creating a feature branch to work on.
Challenging
During a code review, you notice a teammate's pull request for 'Add user profile page' also includes an unrelated fix for a bug in the website's footer. What is the most constructive feedback you can give?
A.Approve the pull request immediately because it fixes a bug.
B.Suggest that the bug fix should be moved to a separate branch and its own pull request.
C.Reject the pull request and tell them to be more careful next time.
D.Delete their branch from the remote repository to teach them a lesson.
Challenging
A developer creates a branch, works for two days, and commits their code. When they run `git push`, they get an error. They realize they forgot to `git pull` before starting. Now, their local branch is based on an old version of `main`, and the remote `main` has new commits. What is the root cause of their problem and the best first step to fix it?
A.Cause: Their internet is down. Fix: Check their connection.
B.Cause: They used a bad commit message. Fix: Amend the commit message.
C.Cause: Their local branch has diverged from the remote. Fix: Pull the latest changes from `main` and resolve any merge conflicts.
D.Cause: The GitHub server is down. Fix: Delete their local repository and clone it again when the server is back up.
Want to practice and check your answers?
Sign up to access all questions with instant feedback, explanations, and progress tracking.
Start Practicing Free