How to Push a Local Repository to GitHub: A Simple Step-by-Step Guide for Beginners
Learn how to take your local project and publish it on GitHub using easy Git commands. A solution for technical writers and first-time users.
If you have just finished writing a user guide, documenting an API, or creating a small project on your computer, you might wonder how to share it with others. Many beginners, especially technical writers, find the process of using GitHub a little confusing the first time. The good news is that once you understand the basic flow, it becomes simple and almost automatic.
This article explains how to move a folder from your computer to a new GitHub repository using a few easy commands. You will also learn what each command does so you can confidently repeat the process on your own.
Let’s get ready
Before you begin, make sure of three things:
You have a GitHub account
Git is installed on your system (you can check by typing git --version in your terminal)
You have a folder on your computer that you want to upload
Once these are in place, you are ready to start.
Now, turn Your Folder into a Git Repository
Open your terminal and write the given command. It’ll move your project folder.
cd path/to/your/project |
Then initialize Git with following command:
git init |
This command prepares your folder for version control. It creates a hidden .git directory that keeps track of every change you make. You can think of it as telling Git to start paying attention to your work.
It’s time to add a file to track
Most projects start with a README file. It introduces your project and appears automatically on your GitHub page. If you do not have one yet, create it:
echo "# My First Git Project" >> README.md |
Now let Git know that it should include this file in the next save:
git add README.md |
The command means “Git, please notice this file and include it when I save my progress.”
Save your work
Saving your current state in Git is called making a commit. It captures a snapshot of your files at that moment.
git commit -m "first commit" |
The message inside the quotes describes what you did in this commit. It helps you or your teammates understand your work later.
It’s better to set the Main branch
By default, Git names your first branch “master.” GitHub prefers the name “main.” You can rename it for consistency:
git branch -M main |
Your main branch now matches what GitHub uses.
Connect Your Folder to GitHub
Go to your GitHub account and click New Repository.
Give it a simple name such as git-test. Leave all checkboxes empty so the repository starts blank.
After it is created, copy the repository URL. It should look something like this:
https://github.com/<username>/git-test.git |
Now link your local folder to this online repository:
git remote add origin https://github.com/<username>/git-test.git |
The word “origin” is a short label for your remote GitHub repository.
Now send your project files to GitHub
git push -u origin main |
The above given command uploads your files from your computer to the main branch of your GitHub repository. The -u flag tells Git to remember this connection, so next time you can use git push without mentioning main
Once the push is done, open your repository on GitHub and refresh the page.
Your project is now online.
Conclusion
When we started this guide, the goal was to make pushing a local project to GitHub simple and approachable. If you have followed the steps and reached this point, you have achieved that goal.
You now know how to create a repository, commit your work, connect it to GitHub, and publish it online. These are the same steps that developers and documentation teams rely on every day to manage and share their projects.
Take a moment to visit your GitHub page and see your work live. What started as a folder on your computer is now part of the open, collaborative world of GitHub. That small moment of seeing your project online is proof that you have learned something meaningful.
You have not just run a few Git commands. You have learned a workflow that will help you grow as a technical writer, collaborate with teams, and confidently contribute to real projects.