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
- Go to GitHub
 - Click “New repository”
 - Enter a repository name
 - DO NOT select “Add README”, “Add .gitignore”, or a license — this keeps the repo truly empty
 - 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
| Task | Command / Action | 
|---|---|
| Initialize local repo | git init | 
| Create GitHub repo | Use GitHub web UI (no README, no gitignore) | 
| Add remote URL | git remote add origin <remote-url> | 
| First commit (optional) | git add . && git commit -m "Initial commit" | 
| Push to GitHub | git push -u origin main | 
🧠 Final Tips
- Use 
.gitignoreto exclude unnecessary files - Use 
git statusto track changes at any time - A repo with no commits is considered completely empty — even 
git pushwon’t work until you commit at least once