Push your project
Upload your work to GitHub
Your commits are on your computer, and an empty repo is waiting on GitHub. Now let's connect them and upload your work.
What is pushing?
Pushing is like syncing your phone photos to the cloud. Your commits travel from your computer to GitHub. Pulling is the opposite: you download new commits from GitHub to your computer.
- Remote: a copy of your repo that lives somewhere else, like GitHub
- origin: the usual nickname for your main remote
- Push: upload your commits to the remote
- Pull: download new commits from the remote
Step 1: Protect your secrets first
Before anything goes online, make sure secret files stay behind. A .gitignore file is a list of things Git should never save. Create it in your project folder:
# Secrets - never upload these
.env
.env.local
# Installed packages - can be re-downloaded
node_modules/
# System junk
.DS_StoreLet's break this down:
.envand.env.localhold your API keys. You learned about them in the secrets lessonsnode_modulesis a huge folder of downloaded code. It can be rebuilt anytime- Lines starting with
#are comments for humans
Commit the new file:
git add .
git commit -m "Add .gitignore for secrets and node_modules"Step 2: Connect and push
Copy the link from your new GitHub repo page. It looks like https://github.com/your-name/my-first-repo.git. Then run:
git remote add origin https://github.com/your-name/my-first-repo.git
git branch -M main
git push -u origin maingit remote add origin ...tells Git where your GitHub copy livesgit branch -M mainnames your main branchmain, which GitHub expectsgit push -u origin mainuploads your commits. The-uremembers the target, so next time you only typegit push
Step 3: Sign in
The first time you push, GitHub needs to know it's really you. Your GitHub password does not work in the terminal. Use one of these easy options:
- Browser sign-in: on Windows and Mac, a browser window often opens. Click to approve and you're done
- GitHub CLI: install it from
cli.github.com, then rungh auth loginand follow the questions - VS Code: use the Source Control panel and click "Publish" or "Sync". VS Code asks you to sign in with GitHub in the browser
gh auth loginRefresh your GitHub repo page. You should now see your files and your commit messages.
The everyday routine
From now on, saving and backing up is three commands:
git add .
git commit -m "Describe the change"
git pushIf you change files on GitHub's website, or an AI builder pushes for you, download those changes with:
git pullYou can also ask Claude Code to do it all:
Check that .env and node_modules are in .gitignore.
Then commit my changes with a clear message and push to GitHub.Troubleshooting
Common mistakes
- Wrong: pushing before creating
.gitignore. Right: add.gitignorefirst, then push. - Wrong: typing your GitHub password when the terminal asks. Right: use browser sign-in,
gh auth login, or VS Code. - Wrong: committing but forgetting to push. Right: check GitHub to see your latest commit.
Practice
Try these exercises to lock in what you just learned.
What's next?
You can now save your work and back it up online. Next, let's see how AI app builders can build a whole web app from a chat, starting with the AI app builders overview.