free course · YouTube + GitHub
Git & GitHub
From your first commit to a reviewed pull request that deploys itself.
- modules
- 4
- modules
- lessons
- 12
- lessons
- real pull request
- 1
- real pull request
- to start
- $0
- to start
what we will cover
Four modules. Twelve lessons.
From your first commit to a protected main branch with a pipeline on every pull request.
- 01Git Basics
- 01Your First Repository
- 02Commits — Save Points for Code
- 03Undo Anything
- 02Branching & Merging
- 04Branches Explained
- 05Merge Conflicts, Calmly
- 06Rebase & a Clean History
- 03GitHub Workflow
- 07Remotes, Push & Pull
- 08Pull Requests & Code Review
- 09Protect main, Tag Releases
- 04Git for DevOps
- 10The Team Branching Model
- 11Git Triggers Everything
- 12Capstone: A Repo a Team Could Use
why version control
Code without Git is a folder full of final_v2.
- Nothing is ever lostEvery version of every file, kept forever.
- Many people, one codebaseEveryone works at once, Git puts it back together.
- Every DevOps job needs itCI/CD, GitOps and Terraform all start in a repo.
- ✕app_final.py
- ✕app_final_v2.py
- ✕app_FINAL_real.py
- ✕app_v2_ali.py
Which one is live? Nobody knows.
- feat: checkout pagee4f1c2a · muh
- fix: total rounding9b3d07e · sara
- test: cover coupons1c8a4f6 · muh
One file. Every version, named and traceable.
the question everybody asks
Git is the tool. GitHub is the website.
They are two different things with confusingly similar names. Here is the whole difference.
- Saves every version of your files
- Works with no internet at all
- You install it once, like any tool
- Stores a copy your team can reach
- Adds pull requests and reviews
- Runs your pipelines on every push
You can use Git with no GitHub account at all. Teams just find that lonely.
step one
Install Git — one command.
Pick your operating system. That is the whole install.
Windows
$ winget install Git.GitmacOS
$ brew install gitUbuntu / WSL
$ sudo apt install gitThen check it worked: git --version
step two
Tell Git who you are.
Four commands, once per machine. Then you never touch this again.
$ git config --global user.name "Your Name"# your name, stamped on every commit
$ git config --global user.email "you@mail.com"# use the same email as your GitHub account
$ git config --global init.defaultBranch main# call the first branch main, not master
$ ssh-keygen -t ed25519# make a key, so GitHub stops asking for passwords
the one idea to get right
Your code lives in four places.
Almost every Git command just moves your work from one box to the next.
- Working directorythe files you are editing
git add - Staging areawhat goes in the next commit
git commit - Local repositoryevery commit, on your laptop
git push - GitHubthe copy your team shares
- Working directorythe files you are editing
- Staging areawhat goes in the next commit
- Local repositoryevery commit, on your laptop
- GitHubthe copy your team shares
git clone brings it all down · git pull brings the team’s work back to you
Stuck on a Git command? Ask which two boxes it moves your code between.
module 1 of 4
Git Basics
Track your own work — save snapshots, read the history, undo anything.
After this module: You can version any project and walk back any mistake.
git log --onelineHEAD → maina1e93f7docs: write README+145d1e8cfix: validate email+1 −1c07a9b4feat: add login form+48f2b1dechore: init repo+1
Four snapshots — you can go back to any of them.
commita full snapshot of your project, not a diff
lesson 01 of 12
Your First Repository
Turn any folder into a Git repository, and meet the command you will run a thousand times.
A repository is just a folder with a .git directory inside it.
# what you will actually type
git --versioncheck Git is installedgit initturn this folder into a repositorygit statuswhat has changed since the last save?ls -asee the hidden .git folder that appeared.gitignorethe list of files Git must never track
lesson 02 of 12
Commits — Save Points for Code
The everyday loop: change files, stage what you meant to change, save a snapshot.
Stage first, commit second. Staging is you choosing what goes in.
# what you will actually type
git add app.pystage one file for the next commitgit add .stage everything you changedgit commit -m "add login"save the snapshot, with a messagegit log --onelinethe history, one line per commitgit diffshow exactly what changed, line by line
lesson 03 of 12
Undo Anything
The lesson that removes the fear — almost every mistake in Git is reversible.
Nothing is really lost until you run reset --hard. Learn revert first.
# what you will actually type
git restore app.pythrow away unstaged changesgit restore --staged app.pyunstage, but keep the changesgit commit --amendfix the last commit or its messagegit revert <sha>undo a commit by adding the opposite onegit stashpark unfinished work, come back later
module 2 of 4
Branching & Merging
Work on two things at once — branch off, merge back, handle conflicts calmly.
After this module: You can run feature branches and merge them without breaking main.
git log --graphmainfeatureYour branch leaves main, grows, and comes back as one merge.
HEADthe commit you are standing on right now
lesson 04 of 12
Branches Explained
A branch is just a movable label pointing at a commit. Once that clicks, branching stops being scary.
Branching is free. Make one for every task, delete it after merging.
# what you will actually type
git branchlist branches — the star is where you aregit switch -c feature/logincreate a branch and jump onto itgit switch maingo back to the main branchgit merge feature/loginbring that branch’s work into this onegit branch -d feature/logindelete it once it is merged
lesson 05 of 12
Merge Conflicts, Calmly
Two people changed the same line, so Git stops and asks you to decide.
A conflict is not an error. Git is asking a question — answer it and commit.
# what you will actually type
<<<<<<< HEADabove this line is your version>>>>>>> featurebelow is theirs — keep one, or combinegit statusevery file still waiting on your decisiongit add resolved.jstell Git this file is sortedgit merge --abortback out completely, nothing lost
lesson 06 of 12
Rebase & a Clean History
Replay your commits on top of the latest main, so the history reads like a story.
Rebase your own branch. Never rebase something you already shared.
# what you will actually type
git pull --rebaseget the latest main, no extra merge commitgit rebase mainmove your branch on top of maingit rebase -i HEAD~3squash or reword your last 3 commitsgit cherry-pick <sha>take one commit from another branchgit reflogyour safety net — every move Git ever made
module 3 of 4
GitHub Workflow
Put the work online and collaborate the way real teams do.
After this module: You can contribute to any repository on GitHub, including other people’s.
Add login form
#482 · feature/login → main
- CI / testrunning…
- CI / buildrunning…
- reviewrunning…
checks running — merge is blocked
originjust a nickname for your GitHub URL
lesson 07 of 12
Remotes, Push & Pull
Connect your local repository to GitHub over SSH, then move commits both ways.
origin is a nickname. push sends, pull brings back, clone copies it all.
# what you will actually type
ssh-keygen -t ed25519create the key GitHub will trustgit remote add origin <url>point your repo at GitHubgit push -u origin mainupload your commits, first timegit pullfetch the team’s commits and merge them ingit clone <url>copy an existing repo to your machine
lesson 08 of 12
Pull Requests & Code Review
The pull request is where work gets discussed, reviewed and approved.
Small pull requests get reviewed fast. Huge ones sit for days.
# what you will actually type
forkyour own copy of someone else’s repositoryopen a pull requestask to merge your branch into theirsrequest changesthe reviewer saying “not yet”squash and mergeyour branch lands as one clean commitgh pr create --fillopen the pull request from the terminal
lesson 09 of 12
Protect main, Tag Releases
The settings that stop broken code reaching production, and the tags that record what you shipped.
If anyone can push straight to main, main will break. Protect it on day one.
# what you will actually type
branch protectionno direct pushes to mainrequired checkstests must pass before merge is allowedCODEOWNERSauto-assign the right reviewer per foldergit tag -a v1.2.0mark this exact commit as a releasegit push --tagspublish your tags to GitHub
module 4 of 4
Git for DevOps
Use Git the way it is used at work — team branching, CI on every push.
After this module: You can set up a repository a real team could start working in on day one.
git push → a1e93f7- checkout
- test
- build
- deploy
image: app:a1e93f7 — tagged with the exact commit
CIcontinuous integration — merge small, merge often
lesson 10 of 12
The Team Branching Model
The conventions that keep ten engineers out of each other’s way.
main is always deployable. Branches live for days, never for months.
# what you will actually type
mainalways deployable, always greenfeat: add checkouta conventional commit — tools read thisfix: · chore: · docs:the other prefixes you will useshort-lived branchesmerge in a day or two, not a monthgit log --graphsee the branching model, drawn
lesson 11 of 12
Git Triggers Everything
Every push and every pull request can run tests, build an image and deploy.
In DevOps, a git push is the button that starts the whole pipeline.
# what you will actually type
.github/workflows/ci.ymlthe file that defines your pipelineon: [push, pull_request]Git events start the pipeline${{ github.sha }}tag the image with the exact commitsecrets.AWS_ROLEcredentials in GitHub, never in the repoGitOpsthe repo becomes the source of truth for deploys
lesson 12 of 12
Capstone: A Repo a Team Could Use
One repository, built end to end — protected main, CI, a real pull request, a tagged release.
Finish this and you have something real to show in an interview.
# what you will actually type
repo + README + .gitignoreset it up like a professionalprotect mainreviews and passing checks requiredCI on every pull requesttests run before anyone can mergefeature branch → PR → reviewthe loop you repeat for yearstag v1.0.0 → releaseship it, and record what you shipped
the loop you repeat forever
A whole day of Git is eight commands.
Git has hundreds. These are the ones you actually run, in order.
- 1
git pullstart from the team’s latest main
- 2
git switch -c feat/searchone branch per task
- 3
git add -pstage exactly what you meant to
- 4
git commit -m "feat: …"a snapshot with a readable message
- 5
git push -u origin feat/searchsend the branch to GitHub
- 6
gh pr create --fillopen the pull request
- 7
CI runs greentests pass on your branch, not on main
- 8
squash & mergeone clean commit lands on main
the payoff
By the end, this is just how you work.
Never lose work again
Commit, branch and stash so nothing disappears.
Work in parallel, safely
Feature branches and conflicts you can resolve.
Contribute to any repo
Fork, branch, pull request, review.
Wire Git into the pipeline
Pushes run tests, merges trigger deploys.
$ git switch -c fix/session-timeout
$ git commit -m "fix: extend session"
1 file changed, 4 insertions(+)
$ gh pr create --fill
github.com/acme/api/pull/482
CI green · approved · squash-merged