
๐ ๏ธ How I Made My Old Public GitHub Repos Private (All at Once)
Published on April 4, 2025
So recently, I was cleaning up my GitHub profile โ and I realised I had so many random public repos ๐
Some were test projects, some half-done college stuff, and a few experiments I never even finished.
I didnโt want people to see all that junk, but GitHub doesnโt let us make multiple repos private at once using the normal UI.
So I found a simple solution using GitHub CLI. Hereโs what I did ๐
โ Step 1: Install GitHub CLI
I installed GitHub CLI using this command in CMD:
winget install GitHub.cli
If youโre using Linux or Mac, you can check the install guide here: https://cli.github.com/manual/installation
โ Step 2: Login to GitHub from CLI
After installation, I logged in using:
gh auth login
It asked some questions:
-
I selected GitHub.com
-
Then chose HTTPS
-
Then opened browser and signed in โ done.
โ Step 3: Make a List of Repos
Now I made a list of repos I wanted to make private.
Just the repo names โ not the full URL.
For example:
repos=(
test-app
mini-project
random-api
)
โ Step 4: Create Script to Make Repos Private
I created a file called make-private.sh
and added this code:
#!/bin/bash
repos=(
repo1
repo2
repo3
)
username="your_github_username"
for repo in "${repos[@]}"
do
echo "Making $repo private..."
gh repo edit "$username/$repo" --visibility private --accept-visibility-change-consequences
done
Replace:
-
repo1
,repo2
, etc. with your actual repo names -
your_github_username
with your real GitHub username
โ Step 5: Run the Script in Git Bash
Since Iโm on Windows, I opened Git Bash (comes with Git) and ran:
chmod +x make-private.sh
./make-private.sh
Thatโs it! All my selected repos became private. ๐ซก
๐จโ๐ป Bonus Tip: See All Your Public Repos
If you want to list your current public repos, you can run:
gh repo list yourusername --visibility public
Copy the names from here and paste them into your script.
๐ญ Final Thoughts
This small trick helped me clean up my profile fast. Now only my good projects are public โ the rest are hidden from the world ๐
If you're a developer or student like me who has experimented a lot on GitHub, give this method a try. Simple and effective.
Let me know if it worked for you too!
If you found this blog helpful, share it with your dev friends or star my projects on GitHub ๐
-
๐ Portfolio: amanraj.me
-
๐ GitHub: [github.com/huamanraj]
-
๐ผ LinkedIn: [linkedin.com/in/huamanraj]
-
๐ฆ Twitter/X: [x.com/huamanraj]
Thanks for reading! ๐
This article was originally published on Hashnode.