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

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Python Fundamentals

Lesson 52 of 55 · Python

Version Control with Git

Duration: 20 minutes

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.

Previous: Project: Building a Todo AppNext: Type Hinting & Static Typing