Git - How to delete a file from your entire repository history - tutorial 2022

Mini tutorial to remove Go , a file of all your repository history. It can also be used for troubleshooting.

 

Sometimes a type of file weighs down your git repository and during development you decided to ignore these files by adding it to the .gitignore file. By using this method, you slow down the filling of your memory space but what will you do with the heavy files remaining in the history of your repository?

In this tutorial you will discover a good way to delete your file in all the history of your repository. This will save you a lot of space on your hard drive or remote repository.

 

Gtranslate – If you see this error constantly – then please make sure that you are not blocking our IP address: 51.178.161.67 

 

Git - How to remove a file from your entire repository history - tutorial Click to tweet

 

 

Git - How to delete a file from your entire repository history

 

In general, it's easy to delete files in a git commit. Deleting all source code history is not an easy task. The command we are going to post may take time to execute depending on the number of commits in your repository.

The author whoever discovered this command mentioned that it took 10 hours to delete his file from all his git repository history. This is normal because his repository is over 10 years old with over 90k commits.

 

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch path_to_file " HEAD

 

path_to_file  : this is the path to the file you want to delete …

 

Before executing the command, plan something else to do to occupy yourself. Maybe a break tea or coffee.

 

After executing the command, send the new repository to your remote git server with the following command:

 

git push-all

 

We hope we have helped you in this troubleshooting!!

 

 

Subscribe to our newsletter

* Indicates required

 

Auteur: Zetaplus

 

Conclusion

 

You may be interested in Android studio - No value has been specified for property googleServicesResourceRoot et The 21 ugliest animals in the world

 

Git - How to delete a file from your entire repository history - tutorial 2022

 

 

 

 

 

Leave comments

Your email address will not be published. Required fields are marked with *

2 × five =