How to push existing local project to new Git repository is one of the most common tasks every developer needs to know. Whether you’ve built a project locally or started coding offline, you’ll eventually want to upload it to a remote Git repository such as GitHub, GitLab, or Bitbucket.
In this step-by-step guide, you’ll learn exactly how to take your existing local folder, initialize Git, connect it to a new remote repository, and push all your code safely online. This process not only helps you back up your project but also makes it easy to collaborate with other developers and track every change in your codebase.
By the end of this tutorial, you’ll have your entire local project stored securely in a new Git repository — ready to access, share, and manage from anywhere.
Table of Contents
Step 1: Create a New Git Repository
- Go to your chosen hosting service (GitHub, GitLab, Bitbucket, etc.).
- Click the button to create a new, empty repository.
- DO NOT initialize it with a README or license—it should be completely empty.
- After creation, the service will provide you with the remote URL (usually an HTTPS URL). Please copy the URL, you will need this for the next step.


Step 1: Select Your Local Project to Push
Open the folder that contains your existing local project. This is the project you’ll connect and push to your new Git repository.
cd C:\Users\YourName\Projects\my-laravel-appStep 2: Initialize Git in Your Local Project
If your project isn’t already using Git, run git init inside your project folder. This command makes your local project ready to track changes with Git.
git initStep 3: Add All Project Files to Git
Stage all files in your project for the first commit
git add .The dot (
.) means all files and folders in your current directory will be added to Git tracking.
Step 4: Commit Your Files
Create your first commit message:
git commit -m "Initial commit"Step 6: Add Remote Repository URL
Copy your repository’s HTTPS URL from Step 1 and connect it to your local project using
Example:
git remote add origin https://[email protected]/eang_senghok/laravel-vue-auth.gitThen verify:
git remote -vStep 7: Push Existing Local Project to New Git Repository
To upload your project to the new Git repository. This publishes your local code online for the first time.
git branch -M main
git push -u -f origin mainExplain:
-M main renames the branch to main
-u origin main sets your default remote tracking branch
-f Force Push. If your push is rejected due to non-fast-forward updates, you can force the push.
Step 8: Verify Your Repository
Open your repository page and refresh it. You should now see all your local project files successfully pushed to the new Git repository.

Conclusion
That’s it — you’ve just learned how to push existing local project to new Git repository from start to finish. With just a few simple Git commands, you can take any local folder and publish it online, making your project more secure and accessible anywhere.
Now that your code is stored in a remote repository, you can easily pull updates, create new branches, or collaborate with teammates.
👉 Next, check out our guide on How to Set Up SSH Key for GitHub or Bitbucket to strengthen your Git workflow and productivity.







