# 🛠️ How I Made My Old Public GitHub Repos Private (All at Once)

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:

```bash
winget install GitHub.cli
```

If you’re using Linux or Mac, you can check the install guide here: [https://cli.github.com/manual/installation](https://cli.github.com/manual/installation)

---

## ✅ Step 2: Login to GitHub from CLI

After installation, I logged in using:

```bash
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:

```bash
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:

```bash
#!/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:

```bash
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:

```bash
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](http://amanraj.me)
    
* 🐙 GitHub: \[[github.com/huamanraj](http://github.com/huamanraj)\]
    
* 💼 LinkedIn: \[[linkedin.com/in/huamanraj](http://linkedin.com/in/huamanraj)\]
    
* 🐦 Twitter/X: \[[x.com/huamanraj](http://x.com/huamanraj)\]
    

Thanks for reading! 🙌
