Set Up Your First GitHub Repository, Start to Finish
Folder, then GitHub, then Git Bash, then three commands and a remote — the exact order that turns a folder on your PC into a real, working repository.
The first repository I ever created, I did in the wrong order: I'd already been working in the folder for weeks before I ever ran git init, and once I did, Git tried to track every file I'd created since, including a virtual environment folder that had no business being in there. Cleaning that up cost an evening I didn't need to spend. Doing the steps in order the first time avoids all of it.
Start with a folder. Create a new, empty folder on your PC for the project — an existing folder works too, but starting from empty makes the next few steps easier to follow the first time through.
Next, create the repository on GitHub itself, before touching Git Bash at all. On github.com, click New repository, give it a name, and leave it empty — don't check the box to add a README or a .gitignore yet. An empty repository on GitHub is just a destination waiting for your first push; adding files there now only means resolving a merge before you've even started.
Now open Git Bash inside your folder: right-click inside it in File Explorer and choose Git Bash Here. From there, three commands turn the folder into a real, tracked repository and record its first snapshot:
One step is left: pointing your local repository at the empty one you created on GitHub, then sending your commit there. GitHub shows you the exact remote URL to use on the empty repository's page right after you create it — copy it from there rather than typing it by hand.
That's it — you have a real, working repository: history saved locally, and a GitHub copy that matches it. Every future change follows the same rhythm from here: make an edit, then git add it, git commit it, and git push it. The next piece in this series picks up right there, with the everyday commands — push, pull, branch, and merge — that make GitHub useful for actual collaboration, not just backup.
git init
git add .
git commit -m "Initial commit"git init starts tracking the folder. git add . stages every file in it for the next commit. git commit actually saves that snapshot, with a message describing it.
git branch -M main
git remote add origin https://github.com/your-username/your-repo-name.git
git push -u origin maingit branch -M main names your branch main, matching what GitHub expects. git remote add origin points your local repository at the empty one on GitHub. git push -u origin main sends your commit there and remembers the connection, so every push after this one is just git push.
