Get the App
SLTechnology News&Howtos  ›  Development  › 

How does Git delete a file from its entire history

Shulou Source: shulou.com Published: 2022-06-01 05:14:32 10月02日 Update

This article mainly introduces how Git deletes a file from the entire history, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.

Delete a file from the entire history

The code is going to be open source, but what if you find it includes a key file or an intranet ip?

Git filter-branch-- tree-filter'rm-f passwords.txt' HEAD

You can use the filter-branch command, which works by taking each commit checkout out, then executing the command you gave it, like rm-f passwords.txt above, and then commit it back.

⚠️ is a high-risk operation that modifies the chain of historical change records to produce a new commit object. So please notify all developers in the warehouse before execution, and after execution, all developers will continue to develop from the new branch and discard all previous branches.

Thank you for reading this article carefully. I hope the article "how to delete a file from the whole history of Git" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: History files articles development branches commands developers repositories code value brand new interests including principles at the same time keys what to do more friends for Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker Microsoft Shulou Information Shulou Technology