This tutorial explains how to upload your local project to GitHub.
GitHub is a platform where developers store and manage their code using Git, a version control system that tracks changes in files.
Uploading your project to GitHub helps you: - Backup your code online - Track changes - Share projects with others
Open your terminal (Command Prompt, PowerShell, or Terminal) and go to your project folder.
Example:
cd project_folder
What this command does
cd means change directory.
It moves the terminal into the folder where your project files are located.
Run:
git init
What this command does
git init creates a Git repository in your project folder.
Git will now start tracking changes in your files.
It also creates a hidden folder called:
.git
This folder stores the version history of your project.
Run:
git status
What this command does
Shows the current status of your project.
It tells you: - which files are new - which files are modified - which files are ready to commit
Run:
git add .
What this command does
Adds files to the staging area.
The dot . means add all files in the current folder.
These files are now prepared for the next commit.
Run:
git commit -m "first commit"
What this command does
git commit saves a snapshot of your project.
-m allows you to add a message describing the change.
Example messages: - first commit - add login page - fix navbar bug
Go to https://github.com
Click New Repository and create a repository.
After creating it, GitHub will show a repository URL like this: - https://github.com/username/project.git
Run:
git remote add origin https://github.com/username/project.git
What this command does
Connects your local project to the GitHub repository.
origin → name of the remote repositoryRun:
git push origin main
What this command does
Uploads your local commits to GitHub.
git push → send code to remote repository origin → remote repository name main → branch name After running this command, your project will appear on GitHub.
| Command | Purpose |
|---|---|
cd folder |
Move into project directory |
git init |
Initialize Git repository |
git status |
Show repository status |
git add . |
Add files to staging area |
git commit -m "message" |
Save changes |
git remote add origin URL |
Connect project to GitHub |
git push origin main |
Upload code to GitHub |
Your project is now successfully stored on GitHub.