brainax

GitHub: your code in the cloud

Lesson 8 of 26 in the course “Vibe coding”. Free, with animations and a quiz.

Git on your laptop, GitHub in the cloud

Git runs on your computer: all your commits live right in the project folder. GitHub is a website that keeps a copy of that folder in the cloud, meaning on servers on the internet. A project on GitHub is called a repository, or “repo” for short: a folder with the files and the whole commit history. In short: Git is your saves, GitHub is the cloud for them.

Push and pull

Push means sending your new commits from your computer to GitHub. Pull means getting changes from GitHub that you don't have yet. Example: during the day you worked on the site on your college laptop and pushed. In the evening at home you pull on another computer and have the same latest version. In the figure push goes up to the cloud, pull goes down.

Why you need GitHub

One: a backup, meaning a spare copy. You spill tea on your laptop, and the code survives. Two: you can work from any computer. Three: hosting, a service that shows your site to the world, like Cloudflare or Vercel. You connect it to the repository, and after every push it grabs the code and updates the site on its own. That's the side arrow in the figure. Four: AI agents can work with the repository too.

Public or private

A repository can be public: anyone on the internet sees the code. Or private: only you and the people you invite. The trap is that bots scan public repositories around the clock looking for keys. Remember the lesson on keys? If a .env with a key ends up in a public repo, assume the key is already stolen: revoke it and create a new one. Not sure you need public? Go private.

README, .gitignore and license

README.md is the project's front page: GitHub shows it first. It says what the project is and how to run it. .gitignore is a list of files Git must not save. You put .env with keys there, and node_modules, the folder of downloaded libraries (ready-made code by other people), which is easy to download again. One more thing: someone else's code on GitHub can be used only under the terms of its license.

Check yourself

  1. What does push do?
    Correct answer: Sends your commits to GitHub. Push sends commits from your computer to the cloud. Getting changes from the cloud to you is pull.
  2. Why must a .env with a key never go into a public repo?
    Correct answer: Bots scan public repos and will steal the key. Public code is visible to everyone, including bots hunting for keys. If a key got there, revoke it and make a new one.
  3. What goes into the .gitignore file?
    Correct answer: Files that Git must not save. The .gitignore lists what Git skips: .env with keys, node_modules. The project description goes in the README.

← Git: saves like in a game Branches and pull requests →