AZ-400 ยท Repository management
Removing sensitive or unwanted data
git filter-repo and BFG, rewriting history, force-pushing and notifying collaborators, rotating leaked secrets, GitHub support for cached views, purging large blobs.
Key points
- A commit deleting a file does not remove it from history.
- Leaked credential: revoke or rotate it first; it is compromised.
- Purge: rewrite history (git filter-repo or BFG), force-push the rewritten refs.
- Collaborators: re-clone or rebase, never merge old branches back.
- GitHub: Support clears cached views and pull request refs; fork owners clean their forks.
- Same rewrite removes large binaries committed by mistake.
Practice questions
A password was pushed to a repository. What should you do first?
- Delete the file in a new commit
- Revoke or rotate the credential
- Run git gc
- Make the repository private
Show answer
Answer: B. Revoke or rotate the credential
Revoke or rotate the credential first, because once pushed it may already be copied. Rewriting history afterwards cleans the record but cannot undo exposure.
After history has been rewritten and force-pushed, which actions should collaborators and fork owners take?
- Delete old clones and re-clone the repository
- Rebase in-progress branches onto the new history
- Merge their old branches into the new main
- Fork owners remove the data or delete their forks
- Rely on GitHub to clean all forks automatically
Show answer
Answer: A. Delete old clones and re-clone the repository, B. Rebase in-progress branches onto the new history, D. Fork owners remove the data or delete their forks
Delete and re-clone (or follow the cleanup steps), rebase local work onto the new history, and fork owners must clean their own forks. Merging an old branch can reintroduce the data, and GitHub cannot clean forks for their owners.
Deleting a file that contains a secret in a new commit removes the secret from the repository.
Show answer
Answer: False
False. The secret stays in earlier commits and can still be read from history. You must rotate it and rewrite history to purge it.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
