Implement History-Rewriting Processes
The Need to Rewrite History
Removing specific data from source control is a vital practice for maintaining a secure and clean project environment. When sensitive details like passwords, API keys, or massive unneeded files are committed to a Git repository, simply deleting them in a new commit does not solve the problem because the data still exists in the commit history. To protect the project, developers must rewrite the history to erase all past traces of this data. In Azure Repos, running these processes ensures that compromised credentials or extraneous files are permanently removed from cloud storage.
History-Rewriting Techniques
Several specialized tools exist to help developers modify past commits and purge unwanted data. The modern tool of choice is git filter-repo, which is highly recommended because it performs history rewrites quickly and safely. An older built-in option is git filter-branch, which allows for highly customized rewriting tasks but is slower and more complex to use. For teams looking for a simpler alternative, the BFG Repo-Cleaner is a fast third-party tool specifically designed to target and strip out large files or credentials.
Synchronizing with Azure Repos
After a developer successfully rewrites the history on their local machine, they must update the remote repository in Azure Repos. Because the local history no longer matches the cloud version, the developer must perform a force-push to overwrite the old commits. This action can easily disrupt the work of other team members who are working on the same codebase, so it is critical to notify and coordinate with the team beforehand. Once the push is complete, the team must verify that the cloud repository successfully synchronizes and no longer contains the removed data.