Skip to content

Commit a12816b

Browse files
committed
Merge branch 'tk/doc-filter-branch' into maint-1.8.1
Add an example use of "--env-filter" in "filter-branch" documentation. * tk/doc-filter-branch: Documentation: filter-branch env-filter example git-filter-branch.txt: clarify ident variables usage
2 parents 2b0dda5 + 21b6e4f commit a12816b

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

Documentation/git-filter-branch.txt

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ argument is always evaluated in the shell context using the 'eval' command
6464
Prior to that, the $GIT_COMMIT environment variable will be set to contain
6565
the id of the commit being rewritten. Also, GIT_AUTHOR_NAME,
6666
GIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL,
67-
and GIT_COMMITTER_DATE are set according to the current commit. The values
68-
of these variables after the filters have run, are used for the new commit.
67+
and GIT_COMMITTER_DATE are taken from the current commit and exported to
68+
the environment, in order to affect the author and committer identities of
69+
the replacement commit created by linkgit:git-commit-tree[1] after the
70+
filters have run.
71+
6972
If any evaluation of <command> returns a non-zero exit status, the whole
7073
operation will be aborted.
7174

@@ -329,6 +332,26 @@ git filter-branch --msg-filter '
329332
' HEAD~10..HEAD
330333
--------------------------------------------------------
331334

335+
The `--env-filter` option can be used to modify committer and/or author
336+
identity. For example, if you found out that your commits have the wrong
337+
identity due to a misconfigured user.email, you can make a correction,
338+
before publishing the project, like this:
339+
340+
--------------------------------------------------------
341+
git filter-branch --env-filter '
342+
if test "$GIT_AUTHOR_EMAIL" = "root@localhost"
343+
then
344+
345+
export GIT_AUTHOR_EMAIL
346+
fi
347+
if test "$GIT_COMMITTER_EMAIL" = "root@localhost"
348+
then
349+
350+
export GIT_COMMITTER_EMAIL
351+
fi
352+
' -- --all
353+
--------------------------------------------------------
354+
332355
To restrict rewriting to only part of the history, specify a revision
333356
range in addition to the new branch name. The new branch name will
334357
point to the top-most revision that a 'git rev-list' of this range

0 commit comments

Comments
 (0)