diff --git a/Documentation/curated-examples-from-issues.md b/Documentation/curated-examples-from-issues.md new file mode 100644 index 00000000..b7a3b745 --- /dev/null +++ b/Documentation/curated-examples-from-issues.md @@ -0,0 +1,104 @@ +# Curated examples from issues + +Lots of people have filed issues against git-filter-repo, and many times it +boils down into questions of "How do I?" or "Why doesn't this work?" + +I thought I'd collect a bunch of these as example repository filterings +that others may be interested in. + +## Table of Contents + + * [Adding files to root commits](#adding-files-to-root-commits) + +## Adding files to root commits + + + +``` +git filter-repo --commit-callback "if not commit.parents: commit.file_changes += [ + FileChange(b'M', b'README.md', b'$(git hash-object -w '/path/to/existing/README.md')', b'100644'), + FileChange(b'M', b'src/.gitignore', b'$(git hash-object -w '/home/myusers/mymodule.gitignore')', b'100644')]" +``` + +You could also use the [insert-beginning contrib script](../contrib/filter-repo-demos/insert-beginning). + +## + + + preserve git notes + + + explanation of passing user data to callbacks + + + issue that lint-history points to in a comment + + + rewriting a specific branch + + + nuking files previously deleted + + + extract library to separate repo + + + replace words in all commit messages + + + only keep files in repository that are present in latest commit + + + renormalize all end-of-line characters + + + removing spaces at end of lines (user example) + + + having both exclude and include rules for filenames + + + setting executable bit + + + another example for removing paths with a certain extension + + + removing a directory + + + NFD/NFC conversion + + + make committer match current user (to get past push hooks) + + + handling special characters, e.g. accents in names + + + handling repository corruption (old original objects are corrupt) + + + removing all files with a backslash in them (final example is best) + + + replace a binary blob in history + + + callback for lint-history + + + using replace refs to delete old history + + + replacing pngs with compressed alternative + (#537 also used a change.blob_id thingy) + + + + need for a multi-step filtering to avoid path collisions or ordering issues + + + Two things: + textwrap.dedent + easier example of using git-filter-repo as a library