How to Upload Your Project to GitHub Step by Step
Uploading a project to GitHub is a simple process when you follow the correct steps. This guide explains how to upload an existing local project to GitHub using Git.
This tutorial assumes that you already have a GitHub account and are logged in.
We will cover:
- Creating a GitHub repository
- Setting up
.gitignore - Initializing Git
- Adding and committing project files
- Connecting the local project to GitHub
- Pushing the project to GitHub
- Verifying the uploaded project
Step 1: Log In to GitHub
First, go to GitHub and log in using your Google credentials.
After logging in, you will be taken to your GitHub dashboard.
This is your home base where your repositories will appear.
Step 2: Create a New Repository
Click the New icon in the top-right corner and select New repository.
Give your repository a name.
For example:
laravel-docker-project
You can also add a short description if you want.
Next, choose whether the repository should be Public or Private.
Since the project already exists on your computer, do not check the options to automatically add:
- README
.gitignore- License
These will be handled manually.
Click Create repository.
Keep the repository page open because we will need the repository URL later.
Step 3: Open Your Project
Now open your project in Visual Studio Code.
Open the terminal inside your project folder on Windows.
Make sure the terminal is working inside the correct project directory before continuing.
Step 4: Add a .gitignore File
This step is very important, especially for Laravel projects.
Laravel projects contain files and folders that should not be uploaded to GitHub, such as:
vendornode_modules.env
The .env file can contain sensitive information such as database passwords and other configuration details.
Check the .gitignore file in the project root.
Make sure the files and folders that should not be uploaded are included in .gitignore.
This keeps unnecessary and sensitive files out of your GitHub repository.
Step 5: Initialize Git
Now turn your project folder into a Git repository.
Run:
git init
This creates a hidden .git folder that Git uses to track changes in your project.
Step 6: Add and Commit Your Files
Now add your project files to Git:
git add .
This adds everything except the files and folders listed in .gitignore.
For example, your vendor, node_modules, and .env files can remain safely on your computer if they are listed in .gitignore.
Now create your first commit:
git commit -m "Initial project"
This saves the current version of your project as your first Git commit.
Step 7: Connect Your Project to GitHub
Go back to the GitHub repository you created earlier.
You will see the repository URL.
Copy the URL.
Then return to your terminal and run:
git remote add origin YOUR_REPOSITORY_URL
Replace YOUR_REPOSITORY_URL with the URL you copied from GitHub.
Next, set the branch name to main:
git branch -M main
Step 8: Push Your Project to GitHub
Now push your project to GitHub:
git push -u origin main
Git will upload your committed project files to the GitHub repository.
Once the upload finishes, your project files will be available in your GitHub account.
Step 9: Verify Your Project on GitHub
Go back to your GitHub repository page and refresh it.
Your project should now appear in the repository.
You should notice that files and folders such as vendor, node_modules, and .env are not included if they were correctly added to .gitignore.
This is exactly what we want for security and file-size reasons.
GitHub Upload Workflow
The basic workflow for uploading a project to GitHub is:
git add .
git commit -m "Your commit message"
git push
For a new project, the complete process is:
git init
git add .
git commit -m "Initial project"
git remote add origin YOUR_REPOSITORY_URL
git branch -M main
git push -u origin main
That’s it. Your local project has now been successfully uploaded to GitHub.
watch full tutorial on youtube
