Skip to main content
Zee Academy · Lesson 05 · Git and GitHub: Version Control for Your Code

Git and GitHub: From a Local Folder to a Safe Repository in the Cloud

Git tracks every change to your code, and GitHub stores it in the cloud so you can work as a team without worrying about losing the project.

Next lesson

What you will learn

  • Never develop without Git: one wrong move without a backup can wipe out days of work.
  • Keep commits small and clear: each commit does one thing (e.g. "feat: add contact form").
  • Branches: "main" is the production branch; new work happens on separate branches (e.g. "feature/dark-mode").
  • .gitignore: the file where you MUST list node_modules and .env.local so you don't leak your passwords.

Initialising Git and connecting to GitHub

Move your local project to GitHub in 4 commands.

  • 1. git init: starts tracking the current folder.
  • 2. git add .: marks all files to be saved.
  • 3. git commit -m "initial commit": saves a snapshot of the code.
  • 4. git remote add origin <URL> && git push -u origin main: sends it to GitHub.

Keeping secrets safe (.gitignore and .env)

The most common beginner mistake is pushing a .env file with API keys and database credentials to a public GitHub repository.

  • Always add these to .gitignore: .env*.local, node_modules/, .next/, .DS_Store.
  • Use a .env.example file with empty variables as a template for other developers.

Step by step

  1. First push to GitHub

    git init
    git add .
    git commit -m "feat: initial commit"
    git branch -M main
    git remote add origin https://github.com/vas-user/moj-web.git
    git push -u origin main

    This puts your code on GitHub and gets it ready to connect to Vercel.

Tip from practice

If the terminal feels uncomfortable, install GitHub Desktop. It shows code differences (diffs) in a clear visual way.