1CG-ADMIN-REWRITEHIST(1)                                CG-ADMIN-REWRITEHIST(1)
2
3
4

NAME

6       cg-admin-rewritehist - rewrite revision history
7

SYNOPSIS

9       cg-admin-rewritehist [-d TEMPDIR] [-r STARTREV]... [-k KEEPREV]...
10       [FILTERS] DESTBRANCH
11
12

DESCRIPTION

14       Lets you rewrite GIT revision history by creating a new branch from
15       your current branch by applying custom filters on each revision. Those
16       filters can modify each tree (e.g. removing a file or running a perl
17       rewrite on all files) or information about each commit. Otherwise, all
18       information (including original commit times or merge information) will
19       be preserved.
20
21       The command takes the new branch name as a mandatory argument and the
22       filters as optional arguments. If you specify no filters, the commits
23       will be recommitted without any changes, which would normally have no
24       effect and result with the new branch pointing to the same branch as
25       your current branch. (Nevertheless, this may be useful in the future
26       for compensating for some Git bugs or such, therefore such a usage is
27       permitted.)
28
29       WARNING! The rewritten history will have different ids for all the
30       objects and will not converge with the original branch. You will not be
31       able to easily push and distribute the rewritten branch. Please do not
32       use this command if you do not know the full implications, and avoid
33       using it anyway - do not do what a simple single commit on top of the
34       current version would fix.
35
36       Always verify that the rewritten version is correct before disposing
37       the original branch.
38
39

OPTIONS

41       -d TEMPDIR
42              When applying a tree filter, the command needs to temporary
43              checkout the tree to some directory, which may consume
44              considerable space in case of large projects. By default it does
45              this in the .git-rewrite/ directory but you can override that
46              choice by this parameter.
47
48       -r STARTREV
49              Normally, the command will rewrite the entire history. If you
50              pass this argument, though, this will be the first commit it
51              will rewrite and keep the previous commits intact.
52
53       -k KEEPREV
54              If you pass this argument, this commit and all of its
55              predecessors are kept intact.
56
57       -h, --help
58              Print usage summary.
59
60       --long-help
61              Print user manual. The same as found in cg-admin-rewritehist(1).
62
63   Filters
64       The filters are applied in the order as listed below. The COMMAND
65       argument is always evaluated in shell using the eval command. The
66       $GIT_COMMIT environment variable is permanently set to contain the id
67       of the commit being rewritten. The author/committer environment
68       variables are set before the first filter is run.
69
70       A map function is available that takes an "original sha1 id" argument
71       and outputs a "rewritten sha1 id" if the commit has been already
72       rewritten, fails otherwise; the map function can return several ids on
73       separate lines if your commit filter emitted multiple commits (see
74       below).
75
76
77       --env-filter COMMAND
78              This is the filter for modifying the environment in which the
79              commit will be performed. Specifically, you might want to
80              rewrite the author/committer name/email/time environment
81              variables (see cg-commit(1) for details). Do not forget to
82              re-export the variables.
83
84       --tree-filter COMMAND
85              This is the filter for rewriting the tree and its contents. The
86              COMMAND argument is evaluated in shell with the working
87              directory set to the root of the checked out tree. The new tree
88              is then used as-is (new files are auto-added, disappeared files
89              are auto-removed - .gitignore files nor any other ignore rules
90              HAVE NO EFFECT!).
91
92       --index-filter COMMAND
93              This is the filter for rewriting the Git's directory index. It
94              is similar to the tree filter but does not check out the tree,
95              which makes it much faster. However, you must use the lowlevel
96              Git index manipulation commands to do your work.
97
98       --parent-filter COMMAND
99              This is the filter for rewriting the commit's parent list. It
100              will receive the parent string on stdin and shall output the new
101              parent string on stdout. The parent string is in format accepted
102              by git-commit-tree: empty for initial commit, "-p parent" for a
103              normal commit and "-p parent1 -p parent2 -p parent3 ..." for a
104              merge commit.
105
106       --msg-filter COMMAND
107              This is the filter for rewriting the commit messages. The
108              COMMAND argument is evaluated in shell with the original commit
109              message on standard input; its standard output is is used as the
110              new commit message.
111
112       --commit-filter COMMAND
113              If this filter is passed, it will be called instead of the
114              git-commit-tree command, with those arguments:
115
116              TREE_ID [-p PARENT_COMMIT_ID]...
117
118              and the log message on stdin. The commit id is expected on
119              stdout. As a special extension, the commit filter may emit
120              multiple commit ids; in that case, all of them will be used
121              as parents instead of the original commit in further commits.
122

EXAMPLE USAGE

124       Suppose you want to remove a file (containing confidential information
125       or copyright violation) from all commits:
126
127
128       cg-admin-rewritehist --tree-filter 'rm filename' newbranch
129       A significantly faster version:
130
131
132       cg-admin-rewritehist --index-filter 'git-update-index --remove filename' newbranch
133       Now, you will get the rewritten history saved in the branch newbranch
134       (your current branch is left untouched).
135
136       To "etch-graft" a commit to the revision history (set a commit to be
137       the parent of the current initial commit and propagate that):
138
139
140       cg-admin-rewritehist --parent-filter sed\ 's/^$/-p graftcommitid/' newbranch
141       (if the parent string is empty - therefore we are dealing with the
142       initial commit - add graftcommit as a parent). Note that this assumes
143       history with a single root (that is, no cg-merge -j happened). If this
144       is not the case, use:
145
146
147       cg-admin-rewritehist --parent-filter 'cat; [ "$GIT_COMMIT" = "COMMIT" ] && echo "-p GRAFTCOMMIT"' newbranch
148       To remove commits authored by "Darl McBribe" from the history:
149
150
151       cg-admin-rewritehist --commit-filter 'if [ "$GIT_AUTHOR_NAME" = "Darl McBribe" ]; then shift; while [ -n "$1" ]; do shift; echo "$1"; shift; done; else git-commit-tree "$@"; fi' newbranch
152       (the shift magic first throws away the tree id and then the -p
153       parameters). Note that this handles merges properly! In case Darl
154       committed a merge between P1 and P2, it will be propagated properly and
155       all children of the merge will become merge commits with P1,P2 as their
156       parents instead of the merge commit.
157
158       To restrict rewriting to only part of the history, use -r or -k or
159       both. Consider this history:
160
161
162            D--E--F--G--H
163           /     /
164       A--B-----C
165       To rewrite only commits F,G,H, use:
166
167
168       cg-admin-rewritehist -r F ...
169       To rewrite commits E,F,G,H, use one of these:
170
171
172       cg-admin-rewritehist -r E -k C ...
173       cg-admin-rewritehist -k D -k C ...
174
176       Copyright © Petr Baudis, 2006
177
178

SEE ALSO

180       cg-admin-rewritehist is part of cogito(7), a toolkit for managing
181       git(7) trees.
182
183
184
185
186                                  12/11/2006           CG-ADMIN-REWRITEHIST(1)
Impressum