When an API key, token or password is pasted into a GitHub issue, pull request comment, review comment or wiki page, revoke it first and only then clean up, because editing the text does not remove it from GitHub's edit history. This guide walks repository maintainers and security teams through the response for content that lives outside the Git commit history: issue and pull request bodies, comments, edit history and wikis.
Secrets committed to code follow a different path, covered in How to Remove Secrets From Git History. This page deals with the conversation layer around the code, where the rules are different and where many teams assume that "edit and save" is enough. It is not.
This is an independent guide from NHI Mgmt Group, based on GitHub's public documentation as of November 2026. It is not sponsored or reviewed by GitHub. Product features change, so confirm settings against GitHub's current documentation.
Key takeaways
- Revoke or rotate the credential before anything else. GitHub's own guidance on sensitive data says that once a secret is revoked or rotated it can no longer be used for access, and that may be enough on its own.
- Editing a comment leaves the old text in the edit history, which GitHub documents as visible to anyone with read access to the repository. You must also delete the revision from the history.
- Hiding a comment is not removal. GitHub states that hidden comments are minimised but people with read access can expand them.
- The initial body of an issue or pull request cannot be deleted, only edited. Redact the body, then delete the revisions that contained the secret.
- Wikis are Git repositories. A secret in a wiki page lives in wiki commit history and needs the same treatment as a secret in code.
- Assume the secret was copied the moment it was posted: by notification emails, chat and ticketing integrations, bots and anyone watching the repository.
When you need this
Typical triggers include:
- A contributor pastes a full error log, configuration file or
curlcommand into an issue, and the paste includes a bearer token or connection string. - A reviewer suggests a change in a pull request review comment and copies a real key into the suggestion.
- A CI or bot comment echoes environment variables into a pull request conversation.
- A wiki page documents a setup procedure with a working credential "for testing".
- A secret scanning alert, a colleague or an outside reporter points to a secret in one of these locations. The GitHub secret scanning alert response guide covers the alert workflow itself.
Almost every one of these secrets belongs to a non-human identity: a service account, an integration, a deploy key or a cloud workload. That matters for the response, because rotating a machine credential means finding and updating every system that uses it.
Step 1: revoke or rotate the secret
GitHub's documentation on removing sensitive data from a repository states plainly that if the sensitive data is a secret, the first step is to revoke or rotate it, and that once this is done the secret can no longer be used for access. It adds that GitHub Support will only help remove sensitive data where the risk cannot be mitigated by rotating affected credentials. In other words, rotation is the real fix and clean-up is hygiene.
- Identify the credential. Work out which system issued it, which identity it belongs to and what it can do. If you cannot tell, treat it as high privilege.
- Revoke at the issuer. Disable the key, token or password in the system that issued it, not just in the place it is used.
- Issue a replacement and update consumers. Store the new value in your secrets manager and update the pipelines, applications and integrations that depend on it.
- Review use of the old credential. Check the issuer's logs for use of the leaked value between the time it was posted and the time it was revoked, especially from unfamiliar addresses or clients.
If the repository is public, treat the exposure window as starting at the moment the content was posted, however short. If it is private, the audience is everyone with read access, plus anything that received a copy through notifications or integrations.
Step 2: redact the visible content
Now remove the secret from what people can see. The right action depends on where it was posted. GitHub's documentation on managing disruptive comments sets out who can do what:
| Location | Action | Who can do it (per GitHub docs) |
|---|---|---|
| Comment on an issue | Edit to redact, or delete | Edit: anyone with moderate access to the repository. Delete: anyone with write access |
| Comment on a pull request, discussion or commit | Edit to redact, or delete | Anyone with write access |
| Issue or pull request body (the first post) | Edit to redact; cannot be deleted | Per repository permissions; GitHub notes that the initial body cannot be deleted |
| Wiki page | Edit the page, then clean wiki history | Wiki collaborators; see Step 4 |
GitHub's recommended redaction pattern is to edit the comment, delete the content you want to remove, type [REDACTED] in its place, and add a note saying that you edited the comment and, optionally, why. Use a neutral note such as "Credential removed and rotated" rather than describing what the credential was.
Deleting a whole comment is an option when nothing else in it is useful. GitHub notes that deleting a comment creates a timeline event visible to anyone with read access, with the deleter's username shown only to people with write access. If the comment contains useful technical context, editing preserves that context while removing the secret.
Do not rely on hiding. GitHub describes hidden comments as minimised, and people with read access to the repository can expand them. Hiding is for off-topic or resolved conversation, not for sensitive data.
Step 3: delete the revision from edit history
This is the step most often missed. GitHub documents that anyone with read access to a repository can view a comment's edit history, through the edited dropdown at the top of the comment. After you redact a comment, the original text with the secret is still one click away.
GitHub provides a specific control for this. Comment authors and anyone with write access to the repository can delete sensitive information from a comment's edit history:
- Open the comment and select the edited dropdown to show the edit history.
- Open the revision that contains the secret.
- In the top right of the edit history window, select Options, then Delete revision from history.
- Confirm with OK.
GitHub notes that after deletion, the person who made the edit and when they made it remain visible, but the content of the edit is no longer available. Repeat for every revision that contained the secret. A secret added in the original post and carried through several edits will appear in each of those revisions.
Be aware of how GitHub limits history. Its documentation states that a maximum of 100 edits is retained per issue, issue comment, pull request, pull request review comment and commit comment, and that when this is exceeded the oldest intermediate edits are removed while the original content and the most recent 99 edits are always preserved. The original content is always kept, so you cannot wait for a secret in the first version to age out. You must delete that revision explicitly.
Apply the same steps to the body of the issue or pull request, which has its own edit history.
Step 4: clean wiki pages and their history
GitHub's wiki documentation explains that wikis are part of Git repositories, so you can clone them with a URL of the form https://github.com/OWNER/REPOSITORY.wiki.git, edit locally and push. Each wiki edit made in the browser is a commit with an edit message.
That means editing the page in the browser only adds a new commit; the old revision with the secret remains in wiki history and in the page's revision view. To remove it:
- Clone the wiki repository to a clean working directory.
- Rewrite the wiki history to remove the secret, using the same tooling and precautions described in How to Remove Secrets From Git History.
- Force push the rewritten default branch. GitHub notes that only changes pushed to the default branch are made live.
- Check the page history in the browser to confirm the old revisions are gone, and ask anyone who has cloned the wiki to delete and re-clone it.
Rewriting history is disruptive. As with code, it is only worth doing after the credential is revoked, and only where leaving a dead credential visible is not acceptable for your policy or audience.
Step 5: deal with pull request diffs, forks and cached views
A secret pasted into a comment usually stays in the conversation layer. If it also reached the code, for example through a suggested change that was committed, follow the Git history process. GitHub's sensitive data documentation then lists further places the data can survive:
- Forks. If the commit exists in a fork, it remains accessible there. GitHub says you must coordinate with the fork owners, and that it cannot provide contact information for them.
- Cached views and pull request references. GitHub states that you can have cached views and references to sensitive data in pull requests removed by contacting GitHub Support.
- Dereferenced pull requests. Support may offer to dereference a pull request rather than delete it, preserving the conversation but making historical diffs inaccessible. GitHub notes that dereferencing does not remove sensitive data quoted in retained bodies or comments, so the comment clean-up above is still needed.
Remember that GitHub Support will only help where rotation cannot mitigate the risk. If you have rotated the credential, expect the conversation-layer clean-up in Steps 2 to 4 to be your responsibility.
Step 6: clean up the copies outside GitHub
A comment does not stay on GitHub. Depending on your setup, the text may already be in:
- Notification emails to everyone watching the repository or mentioned in the thread.
- Chat channels and ticketing systems that mirror issue and pull request activity.
- Bots, AI assistants and automation that read comments and store or forward them.
- Search indexes, archives and backups that your organisation runs over repository data.
You cannot recall every copy, which is why rotation comes first. Where you control the system, such as an internal chat channel or ticket, delete or redact the copy. For everything else, record that copies may exist and rely on the credential being dead.
Verify it worked
- The old credential fails at the issuer, and the replacement works for every consumer.
- Every comment and body that contained the secret shows the redacted text, and the edit history for each no longer shows the content of any revision that contained it.
- Wiki page history no longer contains the secret, checked both in the browser and in a fresh clone.
- No hidden comments still hold the secret.
- Issuer logs have been reviewed for use of the old credential during the exposure window, and any suspicious use has been escalated as an incident.
- Copies in systems you control have been removed.
Hardening afterwards
- Issue templates. Add a clear warning to bug report templates telling contributors to remove tokens, keys and connection strings from logs before posting.
- Bots and CI output. Make sure pipelines mask secrets and never echo environment variables into pull request comments.
- Secret scanning. Turn on secret scanning and push protection where your plan allows. See How to enable GitHub secret scanning push protection.
- Short-lived credentials. Replace long-lived keys with short-lived, federated credentials so a pasted value expires quickly.
- Runbook. Write this sequence into your incident runbook with named owners for rotation and for repository clean-up, so the response does not depend on who happens to notice.
Common failure patterns
- Editing without deleting the revision. The comment looks clean but the secret sits in the edit history for anyone with read access.
- Hiding instead of redacting. Hidden comments can be expanded by readers.
- Cleaning up before rotating. Time spent on redaction while the credential is live is time an attacker can use it.
- Forgetting the first post. Teams delete comments but leave the secret in the issue body, which cannot be deleted and must be edited.
- Treating wikis like comments. A wiki edit adds a commit; the old revision remains until history is rewritten.
- Ignoring mirrors. The secret survives in notification emails and chat integrations long after GitHub is clean.
Practitioner checklist
- Credential identified, revoked at the issuer and replaced in every consumer.
- Issuer logs reviewed for use during the exposure window.
- Every affected comment and body redacted with
[REDACTED]and a neutral edit note. - Every revision containing the secret deleted from edit history, including the original content.
- No hidden comments left holding the secret.
- Wiki history rewritten and verified, with collaborators told to re-clone.
- Forks, cached views and pull request references handled, contacting GitHub Support only where rotation cannot mitigate the risk.
- Copies in chat, ticketing and other systems you control removed.
- Issue templates, CI masking and secret scanning updated to prevent a repeat.
Standards and references
- GitHub Docs: Tracking changes in a comment
- GitHub Docs: Managing disruptive comments
- GitHub Docs: Removing sensitive data from a repository
- GitHub Docs: Adding or editing wiki pages
- MITRE ATT&CK: T1552 Unsecured Credentials
- MITRE ATT&CK: Credentials In Files
- NIST SP 800-53 Rev 5: IR-4 Incident Handling, IA-5 Authenticator Management
Related NHI Mgmt Group resources: How to Remove Secrets From Git History · How to respond to a GitHub secret scanning alert · Developer Secret Scanning Triage · Git Secret Scanning Guide