← Level 4 – Data pro

Lesson 2 of 6 ⏱ 35 minutes Premium

Git – your backup machine

Learn to save versions of your code like the pros do. If you break something, you can go back.

What Git is

Git is a program that remembers the history of changes in your project. Each “version” is called a commit (a save). Broke your code? Go back to an older commit. Professional developers never work without Git.

⚠️

Install Git and run the first commands with a parent. On a Mac, it’s often already there (git --version). On Windows, download Git for Windows.

Show me: your first repository

Open a terminal in your React or server project folder:

git init

This tells Git: “start tracking changes here.” A hidden folder .git is created.

Add all files to your first commit:

git add .
git commit -m "First version of my website"

Take a look at the history:

git log --oneline

You’ll see something like a1b2c3d First version of my website.

Show me: .gitignore

node_modules should never go into your project – it’s huge and gets downloaded via npm install. Create a file called .gitignore:

node_modules/
dist/
.env
*.db
.DS_Store

Then commit again:

git add .
git commit -m "Added gitignore"

Your turn 💪

  1. In the root of your project (React or server), run git init.
  2. Create a .gitignore following the example above.
  3. Make two commits: one “First version”, another after a small change (e.g. edit the text in your footer).
  4. git log --oneline – can you see both?

Check: You have a repository, a .gitignore, and at least 2 commits. Git only lives on your computer so far – in the next lesson we’ll push it to GitHub.

What to take away from this lesson