Skip to content

Commit 01ee6d5

Browse files
committed
wip
1 parent 9ae4ae6 commit 01ee6d5

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Curated examples from issues
2+
3+
Lots of people have filed issues against git-filter-repo, and many times it
4+
boils down into questions of "How do I?" or "Why doesn't this work?"
5+
6+
I thought I'd collect a bunch of these as example repository filterings
7+
that others may be interested in.
8+
9+
## Table of Contents
10+
11+
* [Adding files to root commits](#adding-files-to-root-commits)
12+
13+
## Adding files to root commits
14+
15+
<!-- https://github.com/newren/git-filter-repo/issues/21 -->
16+
17+
Here's an example that will take `/path/to/existing/README.md` and
18+
store it as `README.md` in the repository, and take
19+
`/home/myusers/mymodule.gitignore` and store it as `src/.gitignore` in
20+
the repository:
21+
22+
```
23+
git filter-repo --commit-callback "if not commit.parents: commit.file_changes += [
24+
FileChange(b'M', b'README.md', b'$(git hash-object -w '/path/to/existing/README.md')', b'100644'),
25+
FileChange(b'M', b'src/.gitignore', b'$(git hash-object -w '/home/myusers/mymodule.gitignore')', b'100644')]"
26+
```
27+
28+
Alternatively, you could also use the [insert-beginning contrib script](../contrib/filter-repo-demos/insert-beginning).
29+
30+
##
31+
32+
<!-- https://github.com/newren/git-filter-repo/issues/22 -->
33+
preserve git notes
34+
35+
<!-- https://github.com/newren/git-filter-repo/issues/31 -->
36+
explanation of passing user data to callbacks
37+
38+
<!-- https://github.com/newren/git-filter-repo/issues/45 -->
39+
issue that lint-history points to in a comment
40+
41+
<!-- https://github.com/newren/git-filter-repo/issues/50 -->
42+
rewriting a specific branch
43+
44+
<!-- https://github.com/newren/git-filter-repo/issues/63 -->
45+
nuking files previously deleted
46+
47+
<!-- https://github.com/newren/git-filter-repo/issues/80 -->
48+
extract library to separate repo
49+
50+
<!-- https://github.com/newren/git-filter-repo/issues/83 -->
51+
replace words in all commit messages
52+
53+
<!-- https://github.com/newren/git-filter-repo/issues/91 -->
54+
only keep files in repository that are present in latest commit
55+
56+
<!-- https://github.com/newren/git-filter-repo/issues/122 -->
57+
renormalize all end-of-line characters
58+
59+
<!-- https://github.com/newren/git-filter-repo/issues/145 -->
60+
removing spaces at end of lines (user example)
61+
62+
<!-- https://github.com/newren/git-filter-repo/issues/230 -->
63+
having both exclude and include rules for filenames
64+
65+
<!-- https://github.com/newren/git-filter-repo/issues/268 -->
66+
setting executable bit
67+
68+
<!-- https://github.com/newren/git-filter-repo/issues/274 -->
69+
another example for removing paths with a certain extension
70+
71+
<!-- https://github.com/newren/git-filter-repo/issues/278 -->
72+
removing a directory
73+
74+
<!-- https://github.com/newren/git-filter-repo/issues/296 -->
75+
NFD/NFC conversion
76+
77+
<!-- https://github.com/newren/git-filter-repo/issues/379 -->
78+
make committer match current user (to get past push hooks)
79+
80+
<!-- https://github.com/newren/git-filter-repo/issues/383 -->
81+
handling special characters, e.g. accents in names
82+
83+
<!-- https://github.com/newren/git-filter-repo/issues/420 -->
84+
handling repository corruption (old original objects are corrupt)
85+
86+
<!-- https://github.com/newren/git-filter-repo/issues/427 -->
87+
removing all files with a backslash in them (final example is best)
88+
89+
<!-- https://github.com/newren/git-filter-repo/issues/436 -->
90+
replace a binary blob in history
91+
92+
<!-- https://github.com/newren/git-filter-repo/pull/542 -->
93+
callback for lint-history
94+
95+
<!-- https://github.com/newren/git-filter-repo/issues/300 -->
96+
using replace refs to delete old history
97+
98+
<!-- https://github.com/newren/git-filter-repo/issues/492 -->
99+
replacing pngs with compressed alternative
100+
(#537 also used a change.blob_id thingy)
101+
102+
<!-- https://github.com/newren/git-filter-repo/issues/490 -->
103+
<!-- https://github.com/newren/git-filter-repo/issues/504 -->
104+
need for a multi-step filtering to avoid path collisions or ordering issues
105+
106+
<!-- https://lore.kernel.org/git/CABPp-BFqbiS8xsbLouNB41QTc5p0hEOy-EoV0Sjnp=xJEShkTw@mail.gmail.com/ -->
107+
Two things:
108+
textwrap.dedent
109+
easier example of using git-filter-repo as a library

0 commit comments

Comments
 (0)