Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git's Filter Branch Command

Git's Filter Branch Command

If you've worked with Git long enough to wish you could modify the history of a repository, this talk is for you. Git's filter-branch command lets you re-write history in an automated way, changing usernames, removing certain commits, or restructuring repositories to have nested folders become the top level folder for potential use as submodules.

Matthew McCullough

June 25, 2012
Tweet

More Decks by Matthew McCullough

Other Decks in Programming

Transcript

  1. — Git Filter-Branch Man Page Lets you rewrite git revision

    history by rewriting the branches mentioned in the <rev-list options>, applying custom filters on each revision. Those filters can modify each tree (e.g. removing a file or running a perl rewrite on all files) or information about each commit. Otherwise, all information (including original commit times or merge information) will be preserved.
  2. git filter-branch --tree-filter 'rm BADFILE' HEAD git filter-branch --tree-filter 'rm

    BADFILE' master git filter-branch --tree-filter 'rm BADFILE' otherbranch git filter-branch --tree-filter 'find . -iname b -exec rm {} \;'
  3. -d