Created a local Git repository and want to share it with the world? Here’s how to publish your project on GitHub!
What Is Publishing?
Publishing means uploading your local repository to GitHub.
Before publishing:
- Code is only on your computer
- No backup
- Can’t share with the team
After publishing:
- Code is on GitHub (in the cloud)
- Accessible from any device
- Can work in a team
- Show it in your portfolio
Method 1: Via GitHub Desktop
Step 1: Create a local repository
If you haven’t done it yet:
- File → New Repository
- Fill in:
- Name:my-awesome-project
- Description: “My first project”
- ✅ Initialize with README - Create Repository
Step 2: Make changes
- Add files to the project folder
- They’ll appear in GitHub Desktop under Changes
- Make a commit:
- Summary:Add project files
- Commit to main
Step 3: Publish!
- Find the Publish repository button (top right)
- A settings window opens:
```
Name: my-awesome-project
Description: My first project
☐ Keep this code private
[Cancel] [Publish Repository]
```
-
Configure the settings:
- Name — can change it
- Description — optional
- Keep this code private — uncheck for a public repository -
Click Publish Repository
-
Wait 10-30 seconds…
✅ Done! Your code is on GitHub!
Verify
- Click View on GitHub
- A browser will open with your repository
- URL will be:
github.com/your-username/my-awesome-project
Public vs Private Repository
Public ✅
Pros:
- ✅ Free and unlimited
- ✅ Visible to everyone on the internet
- ✅ Can show to employers
- ✅ Indexed by search engines
- ✅ Can add to portfolio
Cons:
- ❌ Everyone sees your code
- ❌ Can’t store secrets (API keys, passwords)
When to use:
- Learning projects
- Open source
- Portfolio
- Public libraries
Private 🔒
Pros:
- ✅ Only you and invited users can see it
- ✅ Can store private code
- ✅ Free (used to be paid!)
Cons:
- ❌ Not visible in portfolio
- ❌ Requires inviting collaborators
When to use:
- Commercial projects
- Code with secrets
- Unfinished work
- Internal company tools
What Happens During Publishing?
GitHub Desktop:
- Creates the repository on GitHub.com
- Adds a remote (connection to GitHub):
bash git remote add origin https://github.com/username/repo.git - Pushes all commits
- Pushes all branches
- Sets up tracking
After Publishing
Now you have two places where your code lives:
1. Local
- On your computer
- In the project folder
2. Origin (on GitHub)
- On GitHub’s servers
- Accessible from the internet
Syncing
Upload changes (Push):
- Made commits locally
- Click Push origin (↑)
- Commits are sent to GitHub
Download changes (Pull):
- Someone changed code on GitHub
- Click Pull origin (↓)
- Changes are downloaded to you
Check for updates (Fetch):
- Click Fetch origin
- GitHub Desktop checks for new commits
- Nothing changes locally
Common Issues
“Repository name already exists”
You already have a repository with that name!
Fix:
1. Rename the new one: my-project-v2
2. Or delete the old one on GitHub
3. Or use a different account
“Authentication failed”
GitHub Desktop can’t log in to your account.
Fix:
1. File → Options → Accounts
2. Sign out
3. Sign in again
“Couldn’t publish repository”
Internet problem or GitHub is down.
Fix:
1. Check your internet connection
2. Open github.com in a browser (is it working?)
3. Disable VPN/proxy
4. Try again in a few minutes
Accidentally made it private
No problem! You can change it:
- Open the repository on GitHub
- Settings
- Scroll down → Danger Zone
- Change visibility → Make public
- Confirm
Security: Don’t Publish Secrets!
❌ NEVER publish:
- API keys
- Passwords
- Tokens
- Private keys (SSH, SSL)
.envfiles with secrets- Database credentials
✅ Solution:
Use .gitignore:
# .gitignore
.env
secrets.json
*.key
config/local.py
These files will NOT go into Git!
Pre-publish Checklist
Before clicking Publish:
- ✅ Check
.gitignore— no secrets? - ✅ Read README — is it clear what the project does?
- ✅ Remove temp files (
.DS_Store,Thumbs.db) - ✅ Check the license — added a LICENSE file?
- ✅ Make sure the code works
What’s Next?
After publishing:
- ✅ Add a description on the GitHub page
- ✅ Add topics (tags) for discoverability
- ✅ Create a good README.md
- ✅ Add a license (LICENSE file)
- ✅ Share on social media! 🎉
Your first repository on GitHub is a big step! Congratulations! 🚀
💬 Comments (0)
No comments yet
Be the first to share your opinion about this article!