Slide 1

Slide 1 text

FILTER BRANCH Pruning And Separating Git Repository History

Slide 2

Slide 2 text

@matthewmccull [email protected] github.com/training matthewmccullough

Slide 3

Slide 3 text

The Command

Slide 4

Slide 4 text

Git Filter Branch

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

— Git Filter-Branch Man Page Lets you rewrite git revision history by rewriting the branches mentioned in the , 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.

Slide 8

Slide 8 text

Caution! This re-creates new/different hashes for all modified commits.

Slide 9

Slide 9 text

Caution! This is effectively a new repository that looks a lot like the old repository.

Slide 10

Slide 10 text

Modes

Slide 11

Slide 11 text

--env-filter

Slide 12

Slide 12 text

--tree-filter

Slide 13

Slide 13 text

--index-filter

Slide 14

Slide 14 text

--parent-filter

Slide 15

Slide 15 text

--msg-filter

Slide 16

Slide 16 text

--commit-filter

Slide 17

Slide 17 text

--tag-name-filter

Slide 18

Slide 18 text

--subdirectory-filter

Slide 19

Slide 19 text

Modes In Use

Slide 20

Slide 20 text

--env-filter

Slide 21

Slide 21 text

GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE

Slide 22

Slide 22 text

git filter-branch --env-filter 'export GIT_AUTHOR_NAME Bonzo'

Slide 23

Slide 23 text

--tree-filter

Slide 24

Slide 24 text

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 {} \;'

Slide 25

Slide 25 text

--index-filter

Slide 26

Slide 26 text

much faster for rm

Slide 27

Slide 27 text

git filter-branch --index-filter 'git rm --cached --ignore-unmatch FILENAME' HEAD

Slide 28

Slide 28 text

--parent-filter

Slide 29

Slide 29 text

Graft in a different parent

Slide 30

Slide 30 text

--msg-filter

Slide 31

Slide 31 text

git filter-branch --msg-filter ' sed -e "/^git-svn-id:/d" '

Slide 32

Slide 32 text

git filter-branch --msg-filter ' cat && echo "Signed-off-by Matthew McCullough" ' HEAD~5..HEAD

Slide 33

Slide 33 text

--commit-filter

Slide 34

Slide 34 text

Remove certain commits based on commit contents

Slide 35

Slide 35 text

--tag-name-filter

Slide 36

Slide 36 text

Rename tags

Slide 37

Slide 37 text

--subdirectory-filter

Slide 38

Slide 38 text

git filter-branch --subdirectory-filter OLD -- --all

Slide 39

Slide 39 text

Options

Slide 40

Slide 40 text

--all

Slide 41

Slide 41 text

--prune-empty

Slide 42

Slide 42 text

--original

Slide 43

Slide 43 text

-d

Slide 44

Slide 44 text

--force

Slide 45

Slide 45 text

Closing and Q&A

Slide 46

Slide 46 text

Slide 47

Slide 47 text

github.com/training/free

Slide 48

Slide 48 text

FILTER BRANCH Pruning And Separating Git Repository History