Mastering Version Control
👩🏻
Yasmine
👨🏼🦱
Karim
# The Story Begins
They've been working on it separately all week and put everything in one shared folder: Groupe_Projet_Final.
# The Story Begins
Yasmine has just finished writing all the text, 3 hours of intense writing.
She saves the file and goes to grab a coffee.
# The Story Begins
Karim wakes up, opens the exact same file, adds his designs, charts and images., and hits Save.
His version overwrites Yasmine's, because they were both editing the exact same file, at the same time, in the same folder.
Yasmine’s 3 hours of work?
Gone. Overwritten.
# The Story Begins
report.docxreport_v2.docx report_FINAL.docx report_FINAL_vrai_cette_fois.docx# The Story Begins
# The Story Begins
A system that:
They didn't need a better filename.
They needed a Time Machine.
# The Story Begins
Have you ever accidentally deleted a file you spent hours working on? What did you do to fix it?
Just like you might try to undo a mistake or go back to a previous version of your work, developers use version control to manage changes in their code - safely and efficiently !
# Version control Q&A
When working on a long assignment, how do you track different drafts or changes? do you save different versions like “final,” “final-final,” and “final-v2”?
Developers do something similar but smarter, they use commits to save different versions of their work. No more messy file names!
# Version control Q&A
Ever wanted to try a crazy new idea but worried about ruining your original work?
With version control, you can create a “branch” to experiment with new ideas without affecting the main project. It’s like having a separate area to try out your creative ideas.
# Version control Q&A
# CHAPTER 2
Have you shared a document or presentation with others before?
GitHub is like Google Docs for code, but way more powerful. It lets developers share, review, and improve each other’s code.
# CHAPTER 2
When working in a group, how do you know who changed what?
GitHub automatically tracks every change and who made it, so you’ll never have to wonder who’s responsible for that line of code.
Have you ever accidentally deleted a file you spent hours working on? What did you do to fix it?
# Version control Q&A
# CHAPTER 2
Just like you might try to undo a mistake or go back to a previous version of your work, developers use version control to manage changes in their code - safely and efficiently !
When working on a long assignment, how do you track different drafts or changes? do you save different versions like “final,” “final-final,” and “final-v2”?
# Version control Q&A
# CHAPTER 2
Developers do something similar but smarter, they use commits to save different versions of their work. No more messy file names!
# CHAPTER 2
Ever wanted to try a crazy new idea but worried about ruining your original work?
# CHAPTER 2
With version control, you can create a “branch” to experiment with new ideas without affecting the main project. It’s like having a separate area to try out your creative ideas.
# CHAPTER 2
GitHub is like Google Docs for code, but way more powerful. It lets developers share, review, and improve each other’s code.
# CHAPTER 2
When working in a group, how do you know who changed what?
# CHAPTER 2
GitHub automatically tracks every change and who made it, so you’ll never have to wonder who’s responsible for that line of code.
# CHAPTER 2
It is a system or a tool that tracks and manage every changes to your files over time.
keeping a full history in a special database called a repository
# CHAPTER 2
It is a system or a tool that tracks and manage every changes to your files over time.
It’s like a personal historian for your project , keeping a full record of every change ever made, in a special database called repository.
# CHAPTER 2
Know exactly what changed, when, and who did it.
1.Track changes
Roll back to a previous version if something breaks.
2.Revert mistakes
See differences between updates.
3.Compare versions
Work with others without overwriting each other’s work
4.Collaborate safely
Experiment with new ideas without affecting the main project
5.Create branches
Here's exactly what a VCS would have given them
# CHAPTER 2
Think of VCS as a time machine for your work ✨
Did I just break everything? No problem, let me go back to yesterday’s version!
If something goes wrong, you can always travel back to a version that worked perfectly.
# CHAPTER 2
# The Story Begins
Git is a free and open-source version control system designed to handle everything from small to very large projects with speed and efficiency.
Lightning-fast operations
1.Fast
Easy and powerful
2.Branching & Merging
Every user has a full copy of the project history
3.Distributed
Make commits without an internet connection
4.Offline Work
Cryptographic hashing ensures data integrity
5.Security
Git isn’t just another VCS, it’s the most popular one in the world
Perfect for solo devs, teams, and huge open-source communities
6.Flexibility
# The Story Begins
A commit is a snapshot of your entire project at one exact moment, with a short message explaining what changed.
No more report_FINAL_vrai_cette_fois.docx.
Just: save, describe what you did, done
# The Story Begins
"Added introduction and climate data section" → Snapshot #1
"Fixed typo in slide 4 title" → Snapshot #2
"Added charts to slide 7" → Snapshot #3
Each snapshot is safe, dated, and attributed to whoever made it, and fully reversible.
# The Story Begins
Yasmine has an idea: completely redesign the presentation, new colors, new layout, more graphs.
But she's scared. She doesn't want to break the version that already works.
# The Story Begins
A separate copy of the project where you can experiment freely.
# The Story Begins
The default branch. The official, always-working version.
It's the version you'd hand in if the deadline hit right now.
Yasmine is at home. Karim is at his place.
They want to keep working on the same project, without emailing files back and forth forever.
# GitHub
GitHub is a cloud-based platform for hosting and collaborating on Git repositories.
It provides features like code sharing, review and management, making it a popular tool for developers to work together on projects.
# GitHub
GitHub is more than just a place to store code !
it’s a collaboration hub for developers around the world...
# GitHub
# CHAPTER 2
# CHAPTER 2
# CHAPTER 2
git --version
# PRESENTING CODE
If you see something like git version 2.xx.x, then you're good to go!
# CHAPTER 2
git config --global user.name "YOUR NAME"
# PRESENTING CODE
git config --global user.email "YOUR EMAIL"
git config --global core.editor "code --wait"
# Note : you must add vsc path to the env variable
These details appear in every commit you make, so make them official!
# PRESENTING CODE
Repository => the folder holding all your project's files, commits, and branches.
Branch => a separate copy holding a specific version of the project.
Master/Main => The default, official branch of the repository.
Commit => a saved snapshot of your changes, with a message.
checkout => Switching between the current branch and the one specified in the command.
# PRESENTING CODE
Merge => Combining changes from one branch into another.
Fork => Copying someone else’s repo to work on it independently.
git init # Start a new repository
# PRESENTING CODE
git clone [url] # Copy an existing repo
git status
# Note : Shows the current state of the working directory and staged changes,
# letting you see what’s new or what has been modified.
# PRESENTING CODE
git log
# Note : Shows a log of all previous commits, including commit messages, author names, and commit IDs.
git add <file>
# Note : Stages the specified file(s) for the next commit.
# PRESENTING CODE
git add .
# Note : Stages all files for the next commit.
git commit -m "message"
# Note : Save the changes and adds a message to describe the commit.
git branch <branch-name>
# Note : Creates a new branch, which is like a copy of your project where you can work on new features without affecting the main project.
# PRESENTING CODE
git checkout <branch-name>
# Note :Switches to the specified branch.
git merge <branch-name>
# Note : Merges the specified branch into the current branch, combining changes.
git branch # List branches
git remote add origin <url>
# Note : Connects your local repository to a remote GitHub repository.
# PRESENTING CODE
git push
# Note : Uploads your changes from your local repository to GitHub.
git pull
# Note : Downloads changes from the GitHub repository to your local machine.
git remote -v # Show remote repos
git diff
# Note : Shows unstaged changes.
# PRESENTING CODE
git diff --staged
# Note: Shows staged changes only.
git rm --cached <file>
//Note : Stops tracking a file without deleting it locally.
# PRESENTING CODE
git stash
# Note : Temporarily stores changes so you can work on something else, Saves changes without committing.
# PRESENTING CODE
git stash apply
# Note : Reapplies the stashed changes
git stash pop
# Note : Applies and removes the stash from the list.
# PRESENTING CODE
# PRESENTING CODE
git clone <url>
Copies an entire repository from GitHub to your local machine.
Forking a repository on GitHub creates a copy of it in your account. You can then work on it independently, making changes that don’t affect the original project until you submit a pull request.
# PRESENTING CODE
GitHub allows team members to comment on code, suggest changes, and perform code reviews to ensure quality and consistency.
Pull requests (PRs) are a feature on GitHub that allows developers to propose changes, review code, and discuss updates before merging them into the main branch. A PR is created when you want your code reviewed before it becomes part of the main codebase.
# PRESENTING CODE
Purpose: Specify files or directories that Git should ignore (e.g., sensitive data, build files).
GitHub issues are used for tracking bugs, features, and other tasks related to a project. Project boards allow teams to organize and prioritize work.
# PRESENTING CODE
It's your turn now !
Collaborative Exercice Solution
Let's Prractice all what we've learned today