Git & GitHub from Scratch — Push, Pull, and Clone
Without version control, every time you break a file you’re stuck keeping a manual backup (final_v2_reallyfinal.py). Git records the full history of every change to a project, and GitHub takes that history online and makes it shareable — exactly what runs behind this portfolio and every Python tool built in these tutorials.
Install Git
On Windows, download it from git-scm.com/download/win; keep every installer option at its default. Confirm the install:
git --version
Set your identity (one time only)
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
This is stamped on every commit — it identifies the author of a change, not your GitHub account.
Step 1: Start a real project
Say you want to put the quotes.csv we built in the web scraping tutorial under version control:
cd quotes-project
git init
git init creates a hidden .git folder — from this moment, Git tracks this folder’s history.
Step 2: The core loop — status, add, commit
git status # what changed?
git add quotes.csv # stage the file for commit
git commit -m "Add first version of quotes.csv"
Every commit is a snapshot of the project at that moment, with a message explaining it. git log shows the history of all those snapshots.
The overall cycle runs like this: a change in your working directory → git add → the staging area → git commit → your local repository → git push → GitHub — and back the other way with git pull.
Ignoring files that should never be committed
# .gitignore
__pycache__/
.env
*.log
Tokens, passwords, or huge folders (like node_modules) should never be committed — the exact same rule we warned about in the Telegram bot tutorial.
Step 3: Create a repository on GitHub
- Make a free account at github.com/join
- Click the + button at the top of the page, then New repository — or go straight to github.com/new
- Give it a name (e.g.
quotes-project), choose Public or Private, and click Create repository without adding a README — your project already has files
After creating it, GitHub shows you the repo’s URL, something like:
https://github.com/username/quotes-project.git
Step 4: Connect your local project to GitHub
git remote add origin https://github.com/username/quotes-project.git
git branch -M main
git push -u origin main
remote add origin tells Git “the online copy of this project lives here.” push uploads your commit history there.
Important: GitHub no longer accepts your account password for push. You need to create a Personal Access Token (from GitHub’s token settings) and use that instead of your password, or use SSH. Official docs: Managing your personal access tokens.
Clone: bringing a repo to another machine
On any other machine — a work laptop, a server, or a teammate’s computer:
git clone https://github.com/username/quotes-project.git
This downloads the whole project, including its entire commit history. Docs: Cloning a repository.
Pull: keeping your project in sync
If you pushed a change from another machine, your first machine needs to fetch it:
git pull
Golden rule: always run git pull before starting work on a project, so you start from the latest version.
A quick look at Pull Requests
When several people work on a project — or even just you, reviewing your own changes before they’re final — instead of pushing straight to main, you create a separate branch:
git checkout -b feature/add-tags-column
# … make your changes and commit them …
git push -u origin feature/add-tags-column
GitHub then shows a Compare & pull request button — a pull request means “review these changes, and merge them into main if they’re good.” Docs: About pull requests.
Quick reference
| Command | What it does |
|---|---|
git init | Start version control in a folder |
git status | See what changed |
git add <file> | Stage a file for commit |
git commit -m "…" | Record a snapshot with a message |
git push | Upload commits to GitHub |
git pull | Download new changes from GitHub |
git clone <url> | Download a full copy of a repo |
git log | View commit history |
Exercise
Create a new GitHub repository, put the quotes_selenium.py script from the Selenium tutorial under version control with git init and git add/git commit, then push it. Afterward, clone it into a different folder to confirm everything transferred correctly.