The problem Git solves
Imagine working on a Python project. You’ve probably done this:my_script.pymy_script_v2.pymy_script_v2_final.pymy_script_v2_final_ACTUALLY_FINAL.pymy_script_backup_before_breaking_everything.py
How Git works
Think of Git as taking snapshots of your code:- You write code - Make changes to your files
- You save a snapshot - Called a “commit” in Git
- Git remembers everything - Every snapshot, who made it, when, and why
Key concepts (all you need)
Repository (repo): A project tracked by Git- Your
python-for-aifolder can be a repository
- Like selecting items to put in a box before shipping
- Like saving in a video game - you can always go back
- Backs up your code online
- Get updates when working with others
- How you get AI projects to try
First: Install Git
Check if you have Git:- Windows
- macOS
- Linux
- Download from git-scm.com
- Run the installer
- Keep all default settings
- Restart VS Code after installation
The simplest Git workflow
Here’s literally all you need to know for now:These are terminal commands, not Python code! Run them in VS Code’s terminal.
If you see “fatal: not a git repository”, you need to run
git init first. This only needs to be done once per project.- One by one: Type each command and press Enter
- All together: Copy and paste all three lines - the terminal runs them in sequence
Common questions
Do I need to use the terminal?
Do I need to use the terminal?
No! VS Code has buttons for all Git operations. We’ll show you both ways, but you can stick to clicking buttons if you prefer.
What if I mess up?
What if I mess up?
Git is very forgiving. Every commit is saved forever, so you can always go back. It’s actually harder to lose work with Git than without it.
Is Git the same as GitHub?
Is Git the same as GitHub?
No. Git is the tool on your computer. GitHub is a website that stores Git projects. You can use Git without GitHub, but GitHub makes sharing easier.
What’s next?
Let’s create your GitHub account so you have somewhere to store your code.GitHub setup
Create your account in 5 minutes