Computer Science
Grade 8
20 min
GitHub Basics
GitHub Basics
Tutorial Preview
1
Introduction & Learning Objectives
Learning Objectives
Explain the purpose of branching in a collaborative project.
Create, switch to, and push a new branch to a remote repository.
Merge changes from one branch into another.
Create a Pull Request (PR) to propose changes to a project.
Identify a merge conflict and resolve a simple text-based conflict.
Fork a public repository to create their own copy.
How do thousands of developers work on a massive video game like Fortnite or Minecraft without accidentally deleting each other's code? 🎮 Let's find out!
In this lesson, we'll move beyond basic commits and explore the powerful GitHub tools that teams use to work together safely and efficiently. You'll learn how to work on new features in isolation using 'branches' and then how to c...
2
Key Concepts & Vocabulary
TermDefinitionExample
BranchA parallel version of your repository. It's like a separate timeline where you can work on a new feature or bug fix without affecting the main, stable version of your code.If your main branch has a working website, you could create a `new-header-design` branch to experiment with a new look. The main website stays unchanged while you work.
MergeThe action of taking the changes from one branch and applying them to another. This is how you combine your finished feature back into the main project.After you are happy with your `new-header-design` branch, you 'merge' it into the `main` branch to make your new design live on the website.
Pull Request (PR)A formal request to merge your changes from your branch into another branch (usually the main one)....
3
Core Syntax & Patterns
The Branching Workflow
1. `git branch <branch-name>`
2. `git checkout <branch-name>`
3. [Make your changes]
4. `git add .`
5. `git commit -m "Message"`
6. `git push origin <branch-name>`
This is the standard pattern for working on a new feature. You create a new branch, switch to it, do your work, and then push that specific branch to the remote repository on GitHub.
The Merging Workflow (Local)
1. `git checkout main`
2. `git pull origin main`
3. `git merge <feature-branch-name>`
Use this to combine a feature branch into your main branch on your local machine. Always switch to the receiving branch (`main`) first and make sure it's up-to-date (`pull`) before you merge.
Resolving a Merge Conflict
1. Open the conflicted file.
2. Dele...
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
Easy
In the context of GitHub, what is a 'branch'?
A.backup copy of your entire repository stored in the cloud.
B.parallel version of your repository where you can work on new features without affecting the main version.
C.list of all the changes ever made to a single file.
D.personal copy of someone else's repository that you own.
Easy
What is the primary purpose of creating a Pull Request (PR) on GitHub?
A.To immediately and automatically merge your code into the main branch.
B.To delete a branch after you are finished working on it.
C.To propose your changes to the team, allow for code review, and discuss the changes before merging.
D.To download a copy of the repository to your local machine.
Easy
When you 'fork' a public repository on GitHub, what are you creating?
A.new branch inside the original repository that only you can see.
B.temporary file to test new code that gets deleted later.
C.merge conflict that you are required to solve for the owner.
D.personal copy of the entire repository that lives in your own GitHub account.
Want to practice and check your answers?
Sign up to access all questions with instant feedback, explanations, and progress tracking.
Start Practicing Free