This is a lightweight Go script that lets you bulk update the visibility of your GitHub repositories, switching them between public
or private
, using the GitHub REST API.
It's ideal for developers who want to automate visibility changes across multiple repositories without manually editing each one.
git clone https://github.com/arpansaha13/github-repo-visibility-toggle.git
cd github-repo-visibility-toggle
- Generate a fine-grained personal access token with repository scope.
- Store it in a
.env
file beside the script.
# .env
GITHUB_TOKEN=your_personal_access_token_here
go run update_visibility.go <visibility> <owner/repo> [owner/repo] ...
go run update_visibility.go public username/my-repo username/another-repo
- Uses the GitHub REST API
PATCH
/repos/{owner}/{repo}
endpoint. - Sends a JSON payload with the desired visibility.
- Authenticates using your personal access token.
- Valid visibility values:
public
orprivate
. - Make sure your token has permission to edit the target repositories.
MIT License - Made with ❤️