-
Notifications
You must be signed in to change notification settings - Fork 722
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/21 --> | ||
|
||
``` | ||
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). | ||
|
||
## | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/22 --> | ||
preserve git notes | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/31 --> | ||
explanation of passing user data to callbacks | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/45 --> | ||
issue that lint-history points to in a comment | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/50 --> | ||
rewriting a specific branch | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/63 --> | ||
nuking files previously deleted | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/80 --> | ||
extract library to separate repo | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/83 --> | ||
replace words in all commit messages | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/91 --> | ||
only keep files in repository that are present in latest commit | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/122 --> | ||
renormalize all end-of-line characters | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/145 --> | ||
removing spaces at end of lines (user example) | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/230 --> | ||
having both exclude and include rules for filenames | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/268 --> | ||
setting executable bit | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/274 --> | ||
another example for removing paths with a certain extension | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/278 --> | ||
removing a directory | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/296 --> | ||
NFD/NFC conversion | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/379 --> | ||
make committer match current user (to get past push hooks) | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/383 --> | ||
handling special characters, e.g. accents in names | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/420 --> | ||
handling repository corruption (old original objects are corrupt) | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/427 --> | ||
removing all files with a backslash in them (final example is best) | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/436 --> | ||
replace a binary blob in history | ||
|
||
<!-- https://github.com/newren/git-filter-repo/pull/542 --> | ||
callback for lint-history | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/300 --> | ||
using replace refs to delete old history | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/492 --> | ||
replacing pngs with compressed alternative | ||
(#537 also used a change.blob_id thingy) | ||
|
||
<!-- https://github.com/newren/git-filter-repo/issues/490 --> | ||
<!-- https://github.com/newren/git-filter-repo/issues/504 --> | ||
need for a multi-step filtering to avoid path collisions or ordering issues | ||
|
||
<!-- https://lore.kernel.org/git/CABPp-BFqbiS8xsbLouNB41QTc5p0hEOy-EoV0Sjnp=xJEShkTw@mail.gmail.com/ --> | ||
Two things: | ||
textwrap.dedent | ||
easier example of using git-filter-repo as a library |