Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Version Control with Git | Python Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. Python Fundamentals

Lesson 52 of 55

·Python

Version Control with Git

20 minutes

Course progress95%

What you'll learn

Keep these ideas in mind as you work through the lesson.

5 points
  • Install Git on all major OSes (Windows, macOS, Linux).
  • Core workflow: `git init`, `git add`, `git commit`.
  • Branch to isolate features (`git checkout -b <branch>`).
  • Push/pull with remote repositories (GitHub/GitLab).
  • Use `git status`, `git log`, `git diff`, and `git stash` for everyday productivity.

Version Control with Git

Git is the most widely‑used distributed version‑control system. It lets you track changes, collaborate with teammates, and safely experiment with new features.

1️⃣ Install Git

  • Windows: Download the installer from https://git‑scm.com/download/win.
  • macOS: brew install git (Homebrew) or use the Xcode command‑line tools (xcode-select --install).
  • Linux: sudo apt-get install git (Debian/Ubuntu) or sudo dnf install git (Fedora).

2️⃣ Basic Workflow

# 1. Initialise a new repository (run inside your project folder)
git init

# 2. Stage files for the first commit
git add .

# 3. Commit with a message
git commit -m "Initial commit – project skeleton"

3️⃣ Branching & Merging

# Create a new branch for a feature
git checkout -b feature/login

# After working, stage & commit changes
git add login.py
git commit -m "Add login view"

# Switch back to main and merge
git checkout main
git merge feature/login

4️⃣ Remote Repositories (GitHub example)

# Create a repo on GitHub, then link it locally
git remote add origin https://github.com/<username>/<repo>.git

# Push your local main branch
git push -u origin main

5️⃣ Common Commands Cheat‑Sheet

ActionCommand
View statusgit status
See commit historygit log --oneline --graph --decorate
Discard local changesgit checkout -- <file>
Undo last commit (keep changes)git reset --soft HEAD~1
Stash work in progressgit stash / git stash pop

Once you’re comfortable with these basics you’ll be ready to collaborate on any Python project.

Make it stickPractice what you've learned1 quiz · 5 practical tests · Optional activities from Python FundamentalsBrowse activities
Previous lessonProject: Building a Todo AppContinue to lesson 53Type Hinting & Static TypingBack to Python Fundamentals curriculum