Managing your codebase

Your code needs a home besides your laptop.

Everything so far has lived only on your machine. This lesson connects it to a remote host — GitHub or GitLab — so your history is backed up, your work is shareable, and a simple git push can trigger a real, live deploy.

01

Pick a host: GitHub or GitLab

Both do the same core job — store your Git history remotely, give you a web UI, and connect to deploy tools. Pick one; you can always change your mind later.

GitHub — the standard

The largest ecosystem by far — what most tutorials, templates, and AI coding agents assume by default when they say “push this to GitHub.” Free private repos, built-in CI with Actions, and the account most collaborators already have.

GitLab — the alternative

Does everything GitHub does — free private repos, built-in CI/CD — and this project's own home, gitlab.com/eim_opensource/gravity-python. Worth knowing if you ever need to self-host your own Git server.

Neither is required to build with Gravity — but having your code somewhere besides your laptop means you can't lose a week of work to a spilled coffee.

02

Create repos from the terminal

The official CLI turns “open the website, click New, copy a URL, come back to the terminal” into one command.

gh is GitHub's own CLI. Install it, log in once, and it can create the repo, push your existing code, and open it in the browser.

terminal
brew install gh
gh auth login
gh repo create my-gravity-site --private --source=. --push

Already have a repo? Skip repo create and just run git remote add origin <url> once, then git push -u origin main.

03

Connecting your local code: OAuth vs. an SSH key

Before your terminal is allowed to push anything, it has to prove it's you. Two ways to do that — you only need one.

The easy default — and the right choice for almost everyone. One command opens a browser, you click “Authorize,” and a token gets saved on your machine. No keys to generate or copy.

terminal
brew install gh
gh auth login

Already installed gh and ran this in the “Create a repo” step above? You're already authenticated; nothing left to do here. Using GitLab instead? brew install glab, then glab auth login — same idea.

04

Stage it, commit it, push it

You're connected and authenticated — but nothing goes anywhere until you run this loop. It's the same handful of steps every time, whether you or an AI agent made the change.

Unstaged

Git sees you changed something, but hasn't been told to save it yet. This is where every edit starts — yours or an AI agent's.

Staged

You've told Git “this is what goes in my next commit.” One command moves a change from unstaged to staged.

Four commands, run from inside your repo, every time you want to save progress and send it to your remote.

terminal
git status
git add .
git commit -m "Describe what changed"
git push
git statussee what's unstaged
git add .stage everything — or git add <file> for just one
git commit -m "..."save a snapshot of what's staged
git pushsend your commits to GitHub or GitLab
05

Push a branch, get a deploy — for free

The Get Started lesson had you run make deploy-vercel by hand. Connect your repo instead, and that git push you just ran does the same thing automatically — no command needed.

Manual deploy

You run a command. Every time. Nothing happens until you do.

Push-to-deploy

git push to main — it's live in about a minute. No command to remember.

The connection is one-time, made in Vercel's dashboard (Cloudflare Pages and Netlify work the same way):

  1. Import your GitHub or GitLab repo as a new Vercel project.
  2. Keep the default build settings — Gravity's already set up for this.
  3. Confirm the production branch is main.

From then on, every push to main is a new production deploy, and every push to any other branch gets its own preview URL — so you (or a client) can see a change before it goes live.

prompt
Connect this repository to Vercel: import it as a new project in the Vercel dashboard, keep the default build settings, and confirm the production branch is main. Once that's done, tell me exactly what happens the next time I run `git push`.

Your code has a home. Next: the backend.