Git and GitHub from scratch
You built something with Claude, it works, and you want to save it or put it online.
Everyone says "push it to GitHub", but you've never used git and the terminal throws
fatal: not a git repository at you. Let's take it step by step.
They're two different things that usually go together. Git is the version control: it keeps your project's history on your own machine, saves "snapshots" (commits) of how the code looked at each point, and lets you roll back if something breaks. GitHub is the website where you upload that project to keep it in the cloud, share it, and connect it to tools like Vercel. In plain terms: git is the history, GitHub is the site online.
Check if you already have git
On a Mac it often comes preinstalled. First ask for the version:
git --version
git version 2.45.0 If a number shows up, you're set. If not, install it with Homebrew (one line):
brew install git Tell git who you are
Every commit carries your name and email. You set it once, for all your projects. Use the same email you'll use to open the GitHub account:
git config --global user.name "Your Name"
git config --global user.email "you@email.com" Open your GitHub account
Go to github.com
and create a free account. Note your username, because your projects will live at
github.com/your-username/your-project.
Connect the terminal to GitHub (the easy way)
To push things, your terminal needs to identify itself to GitHub. The simplest route
is the official gh tool. Install it and log in:
brew install gh
gh auth login It asks a couple of questions. Pick GitHub.com, then HTTPS, and when it offers "Login with a web browser", accept: the browser opens, you confirm, and you're done. No fighting with passwords or pasting tokens by hand.
Push your first project
Go into your project folder and create the local repository with three lines: initialize, add everything, and save the first snapshot.
cd my-project
git init
git add .
git commit -m "first commit"
Now create the repo on GitHub and push it, all in one, with gh:
gh repo create my-project --source=. --public --push
That creates github.com/your-username/my-project and pushes your code
there. Swap --public for --private if you don't want anyone
seeing it yet.
The everyday loop
From here on, every time you make progress you save and push the changes with three lines:
git add .
git commit -m "what I changed"
git push If something fails
- command not found: git. It didn't install or the terminal is still on the old PATH. Run
brew install git, close the terminal and open a new one. - fatal: not a git repository. You're in a folder without git. Go into the project folder and run
git initfirst. - It asks for username and password on push. You didn't finish
gh auth login. Run it again and choose HTTPS + browser.
With this you've got the basics: local history with git and an online copy on GitHub. It's the foundation for putting your site on Vercel and for almost any AI workflow.
I build websites, automations, and AI tools, and write up what I learn along the way.
More tutorials ↗