Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Git's Filter Branch Command

943 Aufrufe

Veröffentlicht am

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.

Delivered on June 25, 2012

Veröffentlicht in: Technologie
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

Git's Filter Branch Command

  1. 1. FILTER BRANCH Pruning And Separating Git Repository History
  2. 2. @matthewmccull matthew@github.com github.com/training matthewmccullough
  3. 3. The Command
  4. 4. Git Filter Branch
  5. 5. — 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.
  6. 6. Caution! This re-creates new/different hashes for all modified commits.
  7. 7. Caution! This is effectively a new repository that looks a lot like the old repository.
  8. 8. Modes
  9. 9. --env-filter
  10. 10. --tree-filter
  11. 11. --index-filter
  12. 12. --parent-filter
  13. 13. --msg-filter
  14. 14. --commit-filter
  15. 15. --tag-name-filter
  16. 16. --subdirectory-filter
  17. 17. Modes In Use
  18. 18. --env-filter
  19. 19. GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE
  20. 20. git filter-branch --env-filter 'export GIT_AUTHOR_NAME=Bonzo'
  21. 21. --tree-filter
  22. 22. 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 {} ;'
  23. 23. --index-filter
  24. 24. much faster for rm
  25. 25. git filter-branch --index-filter 'git rm --cached --ignore-unmatch FILENAME' HEAD
  26. 26. --parent-filter
  27. 27. Graft in a different parent
  28. 28. --msg-filter
  29. 29. git filter-branch --msg-filter ' sed -e "/^git-svn-id:/d" '
  30. 30. git filter-branch --msg-filter ' cat && echo "Signed-off-by Matthew McCullough" ' HEAD~5..HEAD
  31. 31. --commit-filter
  32. 32. Remove certain commits based on commit contents
  33. 33. --tag-name-filter
  34. 34. Rename tags
  35. 35. --subdirectory-filter
  36. 36. git filter-branch --subdirectory-filter OLD -- --all
  37. 37. Options
  38. 38. --all
  39. 39. --prune-empty
  40. 40. --original
  41. 41. -d
  42. 42. --force
  43. 43. Closing and Q&A
  44. 44. support@github.com
  45. 45. github.com/training/free
  46. 46. FILTER BRANCH Pruning And Separating Git Repository History

×