Skip to content

Instantly share code, notes, and snippets.

@HorridModz
Created July 31, 2025 04:58
Show Gist options
  • Save HorridModz/39aa0089f88ae61a3200fb26214164cd to your computer and use it in GitHub Desktop.
Save HorridModz/39aa0089f88ae61a3200fb26214164cd to your computer and use it in GitHub Desktop.
Search-Commits-For-Email
"""
Search all of your repositories for commits that contain your email address.
If you realized that you have made some commits with a private email address, you can use this script to find those commits
so you can then take relevant action to preserve your privacy.
This will NOT find commits in repositories that you do not own - those are a different story.
"""
"""
Generated with ChatGPT.
"""
import requests
GITHUB_USERNAME = "USERNAME"
EMAIL_TO_SEARCH = "EMAIL"
GITHUB_TOKEN = "TOKEN" # you might need to generate a new one
headers = {"Authorization": f"token {GITHUB_TOKEN}"}
repos = requests.get(f"https://api.github.com/users/{GITHUB_USERNAME}/repos?per_page=100", headers=headers).json()
for repo in repos:
name = repo["name"]
owner = repo["owner"]["login"]
commits_url = f"https://api.github.com/repos/{owner}/{name}/commits"
params = {"author": EMAIL_TO_SEARCH}
r = requests.get(commits_url, params=params, headers=headers)
commits = r.json()
if r.text != "[]":
print(name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment