Lets assume that I have 100 branches and each branches have file1,file2.....file10. Now I want to delete file2 from all of 100 branches. What should I do to delete that from all branches?
            Asked
            
        
        
            Active
            
        
            Viewed 265 times
        
    1 Answers
0
            
            
        You can use git filter-repo (python-based, to be installed first) for that (since git filter-branch or BFG are obsolete after Git 2.22 or more)
Use a path-based filtering:
git filter-repo --path file2 --invert-path
Its man page mentions, about git filter-branch:
Despite the use of
--alland--tag-name-filter, and filter-branch's manpage claiming that a clone is enough to get rid of old objects, the extra steps to delete the other tags and do anothergcare still required to clean out the old objects and avoid mixing new and old history before pushing somewhere.
git filter-repo will force you to make a backup first, then proceed to change the history of the local repository you are filtering.
Check that all branches have been cleaned up, by looking for file2 in all branches.
git log --all -- file2
 
    
    
        VonC
        
- 1,262,500
- 529
- 4,410
- 5,250
