Backing Up to GitHub
Goal — Push your local history to GitHub so it is safe and shareable.
By the end — Your project mirrored on GitHub, with the everyday push loop in hand.
1Create an empty repository online
On GitHub, click the plus button, then New repository. Name it my-first-site and set it to Private or Public as you prefer.
Do not add a README or .gitignore — your project already has files. Then click Create repository.
2Copy the connection address
GitHub shows a setup page with an HTTPS address ending in .git. Copy it; it looks like https://github.com/you/my-first-site.git.
3Connect your local project to GitHub
Back in your terminal, inside my-first-site, run the command below with your address. origin is just the standard nickname for your main cloud copy.
git remote add origin https://github.com/you/my-first-site.git4Name your main branch
Rename your branch so it matches GitHub's default.
git branch -M main5Push your history up
The -u sets this as the default destination, so future pushes are just git push. You may be asked to log in the first time.
git push -u origin main6See it on GitHub
Refresh your repository page. Your files and commit messages are now there.
7Practice the everyday loop
Change a file locally, commit it, then push to send it up. Refresh GitHub to watch it appear.
git add . && git commit -m "your message" && git pushCloning is the reverse direction: git clone <address> downloads any repository — with its full history — onto your machine. It is how a teammate on Windows gets your project and runs it, an idea you will make solid in Phase 4.
Recap — You mirrored your local history to GitHub and learned the commit-then-push loop that keeps your work backed up and shareable.