Version Control with GitHub
Learn to use Git and GitHub directly from Visual Studio Code by creating a web page and managing multilingual versions with branches.
Introduction
Section titled “Introduction”Creating a GitHub Account
Section titled “Creating a GitHub Account”Register your developer profile:
- Go to github.com and click Sign up.
- Enter your email address, create a secure password, and choose a username.
- Complete the verification and enter the confirmation code you received by email.
Installing and Configuring Git
Section titled “Installing and Configuring Git”An essential prerequisite for managing files locally.
Installation
Section titled “Installation”Download and install Git from the official website git-scm.com (you can accept the default options in the setup wizard).
Configuring Your Name and Email
Section titled “Configuring Your Name and Email”Open the terminal (or the VS Code integrated terminal) and run the following commands, replacing the values with the information associated with your GitHub account:
git config --global user.name "il mio username"git config --global user.email "email@example.com"Creating a Local Project in VS Code
Section titled “Creating a Local Project in VS Code”Set up the initial file for the website:
-
Open VS Code and create a new folder on your computer called
my-first-repo. -
Open the folder in VS Code by selecting File > Open Folder….
-
Create a new file called
index.htmland enter this starter code:index.html <!DOCTYPE html><html lang="it"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Mio Primo Progetto</title></head><body><h1>Hello World</h1></body></html>
Initializing and Publishing to GitHub
Section titled “Initializing and Publishing to GitHub”Stage, commit, and publish to the cloud. VS Code lets you manage the Git workflow using a fully graphical and intuitive interface:
- Click the Source Control icon in the left-hand sidebar (or use the shortcut
Ctrl+Shift+Gon Windows/Linux orCmd+Shift+Gon Mac). - Click the Initialize Repository button.
- Stage your changes: Hover over
index.htmlin the Changes list and click the+button (Stage Changes). The file will move to the Staged Changes section. - Enter a commit message in the text field at the top (for example,
First commit: Hello World) and click Commit. - Click the Publish Branch button.
- If prompted, authorize VS Code to access your GitHub account and select Publish to GitHub public repository.
Working with Branches: Italian vs. English
Section titled “Working with Branches: Italian vs. English”Complete workflow: Edit → Stage → Commit on different branches.
Branches let you develop parallel features without affecting the main branch (main).
-
Branch for the
Section titled “Branch for the italian-version”italian-version- Click
mainin the VS Code status bar at the bottom left. - Select Create new branch…, enter
italian-version, and press Enter. - In
index.html, change the main text inside the<h1>tag:
<h1>Hello World</h1><h1>Ciao Mondo</h1>- Staging: In the Source Control view, click the
+next toindex.htmlto stage the change. - Commit & Publish: Enter the message
Italian translation, click Commit, and then click Publish Branch.
- Click
-
Branch for the
Section titled “Branch for the english-version”english-version- Return to the main branch: click
italian-versionin the bottom-left corner and selectmainfrom the list. Notice thatindex.htmlreturns to its initial version! - Create a new branch called
english-versionby following the same steps. - Add a detail in English to
index.html:
<h1>Hello World</h1><p>Welcome to my first versioned website!</p>- Staging: Click the
+button next toindex.htmlto stage the changes. - Commit & Publish: Enter the message
English version update, click Commit, and then click Publish Branch.
- Return to the main branch: click
Verifying That the Branches Are Different
Section titled “Verifying That the Branches Are Different”To see the real “magic” of Git and confirm that both versions coexist in the same project without overwriting each other, perform these checks:
Locally in VS Code:
Section titled “Locally in VS Code:”- Click the branch name in the bottom-left corner of the VS Code status bar.
- Select
italian-version: look atindex.htmlin the editor and you will see the text “Ciao Mondo”. - Click again and select
english-version: the file will instantly change to show “Hello World” and the new paragraph.
On GitHub:
Section titled “On GitHub:”- Open your repository page on github.com.
- Above the file list in the upper-left corner, click the dropdown labeled
main(or Branches). - Select
italian-versionorenglish-versionto browse the branches: you will see the code inindex.htmlchange instantly depending on the selected branch!
Summary
Section titled “Summary”Knowledge Check
Section titled “Knowledge Check”Your answers to the quizzes on this page are saved in your browser's local storage and remain stored between visits.
What is the difference between Git and GitHub?
- Git is an online service, while GitHub is the program installed on your computer.
- Git is a version control system; GitHub is an online platform that hosts Git repositories.
Correct: Git manages the project’s history, while GitHub lets you host and share repositories online.
- They are two different names for the same tool.
What is staging used for before creating a commit?
- To automatically publish all changes to GitHub.
- To select the changes to include in the next commit.
Correct: staging lets you choose which changes to save in the next revision.
- To create a new branch without saving changes.
What does a commit record?
- A public copy of the project on GitHub.
- A revision of the selected changes, accompanied by a descriptive message.
Correct: a commit saves the staged changes in the repository’s history.
- Automatically switching from the current branch to
main.
Why create a branch for an alternative version of the page?
- To necessarily overwrite the contents of the
mainbranch. - To work on a separate line of development without immediately changing other branches.
Correct: each branch can contain a distinct version of the project, and you can switch between them.
- To turn a local repository into a GitHub account.
What happens when you publish a branch?
- The local branch is deleted after a commit is created.
- The local branch is sent to the remote repository on GitHub.
Correct: publishing makes the branch available in the remote repository as well.
- All repository branches are merged automatically.
Quiz progress
0 / 0 questions answered (0%)
0 correct answers
Your score
0%
0 / 0 correct answers
Answered: 0 / 0 (0%)
STICS © 2026 by Carlo Scocco is licensed under CC BY-NC 4.0