PY-1.4-BP1-MQ10

Our Goal: Why Use Branches?

Imagine you have a working game. You want to add a new feature, like a score. Should you change the main game directly? Or should you work on a separate copy? In this lesson, you will learn why it's better to work on a separate copy, called a 'branch', when adding new things to your code. This keeps your main game safe and working.

Here's what a blank Pygame window looks like:

<svg width="800" height="600" xmlns="http://www.w3.org/2000/svg">
  <rect width="800" height="600" fill="#CCCCCC"/>
  <text x="50%" y="50%" font-family="Arial" font-size="30" fill="#333333" text-anchor="middle" alignment-baseline="middle">Pygame Window</text>
</svg>

Check Your Work

Before you start, let's see how things are right now. We have a basic Pygame project. Your job is to explain why using branches is a good idea, not to write code. But we can still check if the basic project works.

Run this command in your terminal to check the project:

pytest module-1.4/blueprint-BP1/quest-10

What you should see:

āŒ Some tests will fail. This is okay for now! It means the project is ready for you to start explaining things.

Write Your Explanation

Now it's time to write your explanation! Your main task is to write one paragraph. This paragraph should explain why it's better to use a separate 'branch' when you add a new feature to your code, instead of changing the main code directly.

Think about what you learned from the documentation. Why is it safer and better to work on a copy?

Here are some Git commands you might have seen in the documentation. These commands help you work with branches, but remember, your main task is to explain the idea, not to use these commands right now.

To create a new branch (a copy):

git branch new-feature-name

To switch to that new branch:

git checkout new-feature-name

To save your changes on your branch:

git add .
git commit -m "My changes"

To bring changes from a branch back to the main code:

git merge new-feature-name

Check Your Work Again

You've written your explanation! Now, let's check the project again to make sure everything is still working. Even though you didn't write code, it's good to check.

Run this command in your terminal:

pytest module-1.4/blueprint-BP1/quest-10

What you should see:

āœ… All tests should pass! This means the basic project is still good to go.

What You Learned

Great job! You finished this lesson.

You learned why using 'branches' in Git is a smart way to work on your code. It helps keep your main project safe while you add new things. This is a very important idea when you work on projects with others or want to keep your code organized.

This idea will help you in future lessons when you start using Git commands more.

Documentation

Documentation not available for PY-1.4-BP1.