Git Filter-Branch Examples

Posted by: Matthew McCullough on December 31, 2010

Have you ever looked at the powerful git filter-branch command? It offers, amongst many features, the ability to maintain history while re-writing the tree to a subset of its past self. A common use case is to prune out a large and unnecessary folder of binaries that was never intended to be under version control.

The filter-branch command can be very confusing at first. What’s needed is a set of working examples. I’ve got 5 scripted flows to show you how to use it. Just hop over to my ever-growing git workbook that I use for workshops and look for module #27 as PDF or as HTML. There’s a corresponding set of samples in the example-repos directory.

If you are interested in more of these type of advanced moves with Git, stay tuned for my upcoming O’Reilly Git Master Class videos (directly O’Reilly link soon), monthly Git trainings via, No Fluff Just Stuff tour stops, or one of my international conferences hosting my Git talks.

Matthew McCullough

About Matthew McCullough

Matthew McCullough is an energetic 15 year veteran of enterprise software development, open source education, and co-founder of Ambient Ideas, LLC, a Denver consultancy. Matthew currently is VP of Training at, author of the Git Master Class series for O'Reilly, speaker at over 30 national and international conferences, author of three of the top 10 DZone RefCards, and President of the Denver Open Source Users Group. His current topics of research center around project automation: build tools (Gradle), distributed version control (Git, GitHub), Continuous Integration (Jenkins, Travis) and Quality Metrics (Sonar). Matthew resides in Denver, Colorado with his beautiful wife and two young daughters, who are active in nearly every outdoor activity Colorado has to offer.

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »