How to Push a Folder to GitHub – Step-by-Step Guide

Whether you’re starting a new project or uploading an existing one, pushing a local folder to GitHub helps you track changes, collaborate, and share your work. This guide walks you through the process from start to finish using Git and GitHub.


🛠️ Prerequisites

Before you begin, make sure you have:


🚀 Steps to Push a Folder to GitHub

✅ 1. Create a Repository on GitHub

  1. Go to GitHub
  2. Click New repository
  3. Enter a name, choose visibility (public/private), and click Create repository
  4. Do not initialize with README if you’re pushing an existing folder

GitHub will now show you commands to push a project. Let’s do it locally.


📂 2. Open Terminal and Navigate to Your Folder

cd path/to/your-folder

This is the folder you want to push to GitHub.


🧰 3. Initialize a Git Repository

If this is not already a Git project:

git init

This creates a .git folder and begins tracking changes.


➕ 4. Add and Commit Your Files

git add .
git commit -m "Initial commit"

This stages and commits all files in the folder.


🌐 5. Add Remote Repository

Copy the URL of your GitHub repo (e.g., https://github.com/yourusername/your-repo.git) and run:

git remote add origin https://github.com/yourusername/your-repo.git

☁️ 6. Push to GitHub

git push -u origin main

If your local branch is named master, replace main with master:

git push -u origin master

You may be prompted to log in or authenticate via token or SSH, depending on your setup.


🎉 Done!

Visit your GitHub repository page — your folder and files should now be visible there.


🔁 Quick Summary

StepCommand
Navigate to foldercd your-folder
Initialize Gitgit init
Stage filesgit add .
Commit changesgit commit -m "Initial commit"
Link to GitHub repogit remote add origin <repo-url>
Push to GitHubgit push -u origin main

🧠 Pro Tips

  • Add a .gitignore file to exclude unnecessary files (e.g., node_modules, *.log)
  • Use SSH keys for secure and easy GitHub authentication
  • For future pushes, use just: git add . git commit -m "Your message" git push
Sharing Is Caring:

Leave a Comment