How to Create an Empty Git Repository (Locally & Remotely)

Whether you’re starting a new project or setting up version control for existing code, creating an empty Git repository is your first step in using Git effectively.

In this guide, we’ll walk through:

  • Creating an empty local Git repository
  • Creating an empty remote GitHub repository
  • Connecting the two

🧰 1. Create an Empty Git Repository Locally

Step 1: Open Terminal or Git Bash

Navigate to the folder where you want the repository:

cd path/to/your-project

Step 2: Initialize the Repository

git init

This creates an empty .git/ directory in your folder, which tracks all changes.

✅ You now have an empty local Git repository.


🌐 2. Create an Empty Repository on GitHub

  1. Go to GitHub
  2. Click “New repository”
  3. Enter a repository name
  4. DO NOT select “Add README”, “Add .gitignore”, or a license — this keeps the repo truly empty
  5. Click Create repository

GitHub will now show you setup instructions with a remote URL like:

https://github.com/yourusername/your-repo.git

🔗 3. Connect Local Repository to Remote (Optional)

If you want to push to GitHub, link your local repo:

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

If your branch is named main:

git push -u origin main

Or if it’s master:

git push -u origin master

You may need to create a first commit before pushing:

git add .
git commit -m "Initial commit"

📌 Summary

TaskCommand / Action
Initialize local repogit init
Create GitHub repoUse GitHub web UI (no README, no gitignore)
Add remote URLgit remote add origin <remote-url>
First commit (optional)git add . && git commit -m "Initial commit"
Push to GitHubgit push -u origin main

🧠 Final Tips

  • Use .gitignore to exclude unnecessary files
  • Use git status to track changes at any time
  • A repo with no commits is considered completely empty — even git push won’t work until you commit at least once
Sharing Is Caring:

Leave a Comment