Version Control

Git & GitHub

Git records every change to your code. GitHub hosts the shared team repository online.

Why we use it

Git is mandatory in this module. Every team member must commit on their own branch, because your commit history shows your individual contribution to the coursework.

Git vs GitHub

GitGitHub
A program on your laptopA website that hosts repos
Tracks changes, commits, branchesShares the repo with your team, pull requests

The team workflow

git switch -c ali/login-screen   # 1. your own branch
git add .                         # 2. stage
git commit -m "Add login screen"  # 3. commit
git push -u origin ali/login-screen  # 4. push → open a Pull Request
git switch main && git pull       # 5. after merge: update main

Important

Never work directly on main. One branch per member (or per feature), merged through a Pull Request.

Useful extensions

GitHub account
Free at github.com. Use your real name so we can match your commits to you.
GitLens (VS Code)
Shows who changed each line and when.
GitHub CLI (gh)
Optional: create repos and sign in from the terminal.

Common problems

Authentication failed on git push
Fix

GitHub doesn't accept passwords. Sign in through the browser pop-up (Git Credential Manager) or with the GitHub CLI.

Run
gh auth login
"remote origin already exists"
Fix

Point it at the right URL instead of adding it again.

Run
git remote set-url origin <repository-url>