How do I put my project on GitHub?
You have a project folder. You want it on GitHub so you can share it or open it from another computer.
Do these steps in order.
Step 1: Make sure your folder is a Git repo
Section titled “Step 1: Make sure your folder is a Git repo”Open a terminal. Go into your project folder. Run:
git statusIf you see “not a git repository”, your folder is not a repo yet. Run:
git initThen add and commit at least one time:
git add .git commit -m "First commit"Step 2: Create an empty repo on GitHub
Section titled “Step 2: Create an empty repo on GitHub”- Go to github.com and sign in.
- Click the + at the top right. Click New repository.
- Type a name for the repo (for example
my-project). - Do not check “Add a README” or “Add .gitignore”. Leave the repo empty.
- Click Create repository.
GitHub will show you a page with a URL. It looks like:
https://github.com/your-username/my-project.git
Copy that URL. You need it in the next step.
Step 3: Connect your folder to GitHub
Section titled “Step 3: Connect your folder to GitHub”In the terminal, still in your project folder, run (paste your real URL):
git remote add origin https://github.com/your-username/my-project.git“Origin” is just a name for this place on GitHub. Everyone uses that name. You only do this once per repo.
Step 4: Send your commits to GitHub
Section titled “Step 4: Send your commits to GitHub”Run:
git push -u origin mainIf your branch is called master instead of main, use:
git push -u origin masterThe -u means “remember this”. Next time you can just run git push and Git will know where to send.
Done. Refresh the page on GitHub. You should see your files there.
From now on: when you make more commits, run git push to send them to GitHub.