Adding a Pre-Existing Website to GitHub

Colby Hemond
If you are like me, you don't use GitHub nearly as much as you should. Because of that, you always seem to forget how simple the process of the Git commands can be. Well, fear no more—you might as well bookmark this blog post before you even continue reading. In this post I will outline the following steps:
- Creating the Git repository on your local machine
- Creating the repository on GitHub
- Pushing the repository on your local machine to GitHub
Creating the Git repository on your local machine
First, open up your terminal and cd
into the folder that contains your project. Usually it's just a simple:
cd your-project-here
Next, initialize the Git repository:
git init
Stage all project files for commit:
git add .
The .
means you're adding everything in the folder.
Bonus: Add a .gitignore
file
If you have sensitive files you don’t want tracked by Git (like .env
files), do this:
touch .gitignore
git add .gitignore
Now commit everything:
git commit -m "uploading initial project"
Your project is now committed locally. Next, let’s get it onto GitHub.
Creating the repository on GitHub
- Go to github.com and log in
- Click the + in the top-right corner → New Repository
- Name the repo (ideally the same as your project folder)
- Adjust settings as needed
- Click Create Repository
You now have an empty repo online. Next step: connect it to your local repo.
Pushing the repository on your local machine to GitHub
Back in the terminal, link your local repo to GitHub:
git remote add origin https://github.com/username/new_repo
Replaceusername
with your GitHub username, andnew_repo
with your actual repository name.
Optional: Use SSH instead
If you have SSH set up:
git remote add origin git@github.com:username/new_repo
Now push your files:
git push -u origin master
That’s it! 🎉 Head back to GitHub and refresh the page—you should now see all your project files.
Hope this helped you as much as it’s going to help me next time I forget 😄