Bitzu

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.

Source: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository

Practice questions

Single choice

A password was pushed to a repository. What should you do first?

  1. Delete the file in a new commit
  2. Revoke or rotate the credential
  3. Run git gc
  4. 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.

Select all that apply

After history has been rewritten and force-pushed, which actions should collaborators and fork owners take?

  1. Delete old clones and re-clone the repository
  2. Rebase in-progress branches onto the new history
  3. Merge their old branches into the new main
  4. Fork owners remove the data or delete their forks
  5. 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.

True or false

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.

Download on the App StoreGet it on Google Play

More AZ-400 topics in this module