mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
Add git reauthor (#548)
Based on https://help.github.com/articles/changing-author-info/
This commit is contained in:
parent
f3954e1974
commit
9b3e25f407
1
AUTHORS
1
AUTHORS
|
|
@ -99,6 +99,7 @@ Patches and Suggestions
|
|||
- Carl Casbolt <carl.casbolt@gmail.com>
|
||||
- Ciro Nunes <ciroanunes@gmail.com>
|
||||
- Craig MacGregor <craigerm@gmail.com>
|
||||
- Damien Tardy-Panis <damien@tardypad.me>
|
||||
- Dan Jackson <e28eta@yahoo.com>
|
||||
- Daniel Schildt <daniel@autiomaa.org>
|
||||
- Dave James Miller <dave@davejamesmiller.com>
|
||||
|
|
|
|||
38
Commands.md
38
Commands.md
|
|
@ -38,6 +38,7 @@
|
|||
- [`git psykorebase`](#git-psykorebase)
|
||||
- [`git pull-request`](#git-pull-request)
|
||||
- [`git rebase-patch`](#git-rebase-patch)
|
||||
- [`git reauthor`](#git-reauthor)
|
||||
- [`git release`](#git-release)
|
||||
- [`git rename-tag`](#git-rename-tag)
|
||||
- [`git repl`](#git-repl)
|
||||
|
|
@ -347,6 +348,7 @@ Does the following:
|
|||
- Push the branch / tags
|
||||
- Executes _.git/hooks/post-release.sh_ (if present)
|
||||
|
||||
|
||||
## git rename-tag
|
||||
|
||||
Rename a tag (locally and remotely).
|
||||
|
|
@ -370,6 +372,42 @@ $ git tag
|
|||
test2
|
||||
```
|
||||
|
||||
|
||||
## git reauthor
|
||||
|
||||
Rewrite history to change author's identity.
|
||||
|
||||
Replace the personal email and name of Jack to his work ones
|
||||
```bash
|
||||
$ git reauthor --old-email jack@perso.me --correct-email jack@work.com --correct-name 'Jack Foobar'
|
||||
```
|
||||
|
||||
Replace the email and name of Jack to the ones defined in the Git config
|
||||
```bash
|
||||
$ git reauthor --old-email jack@perso.me --use-config
|
||||
```
|
||||
|
||||
Replace only the email of Jack (keep the name already used)
|
||||
```bash
|
||||
$ git reauthor --old-email jack@perso --correct-email jack@perso.me
|
||||
```
|
||||
|
||||
Change only the committer email of Jack (keep the author email already used)
|
||||
```bash
|
||||
$ git reauthor --old-email jack@perso.me --correct-email jack@work.com --type committer
|
||||
```
|
||||
|
||||
Set Jack's identity as the only one of the whole repository
|
||||
```bash
|
||||
$ git reauthor --all --correct-email jack@perso.me --correct-name Jack
|
||||
```
|
||||
|
||||
Set Jack as the only committer of the whole repository (keeps authors)
|
||||
```bash
|
||||
$ git reauthor --all --correct-email jack@perso.me --correct-name Jack --type committer
|
||||
```
|
||||
|
||||
|
||||
## git alias
|
||||
|
||||
Define, search and show aliases.
|
||||
|
|
|
|||
161
bin/git-reauthor
Executable file
161
bin/git-reauthor
Executable file
|
|
@ -0,0 +1,161 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
init_variables() {
|
||||
COMMAND=${0#*-}
|
||||
|
||||
CONFIG=false
|
||||
ALL=false
|
||||
unset OLD_EMAIL
|
||||
unset CORRECT_EMAIL
|
||||
unset CORRECT_NAME
|
||||
TYPE='both'
|
||||
}
|
||||
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
usage: git ${COMMAND} [<options>]
|
||||
|
||||
Options
|
||||
-a, --all rewrite all identities in commits and tags
|
||||
-c, --use-config define correct values from user Git config
|
||||
-e, --correct-email <email> define the correct email to set
|
||||
-n, --correct-name <name> define the correct name to set
|
||||
-o, --old-email <email> rewrite identities matching old email in commits and tags
|
||||
-t, --type <id> define the type of identities affected by the rewrite
|
||||
author, committer, both (default)
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
error() {
|
||||
if [[ -n "$1" ]]; then
|
||||
local msg=$( echo "error: $1" | sed 's/\\n/\\n /g' )
|
||||
echo -e "${msg}" >&2
|
||||
fi
|
||||
usage
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
reauthor() {
|
||||
local author='
|
||||
if ${ALL} || [ "${GIT_AUTHOR_EMAIL}" = "${OLD_EMAIL}" ]; then
|
||||
[ -z "${CORRECT_EMAIL+x}" ] || export GIT_AUTHOR_EMAIL="${CORRECT_EMAIL}"
|
||||
[ -z "${CORRECT_NAME+x}" ] || export GIT_AUTHOR_NAME="${CORRECT_NAME}"
|
||||
fi
|
||||
'
|
||||
local committer='
|
||||
if ${ALL} || [ "${GIT_COMMITTER_EMAIL}" = "${OLD_EMAIL}" ]; then
|
||||
[ -z "${CORRECT_EMAIL+x}" ] || export GIT_COMMITTER_EMAIL="${CORRECT_EMAIL}"
|
||||
[ -z "${CORRECT_NAME+x}" ] || export GIT_COMMITTER_NAME="${CORRECT_NAME}"
|
||||
fi
|
||||
'
|
||||
local filter
|
||||
|
||||
case "${TYPE}" in
|
||||
author) filter="${author}" ;;
|
||||
committer) filter="${committer}" ;;
|
||||
both) filter="${author} ${committer}" ;;
|
||||
esac
|
||||
|
||||
export ALL
|
||||
export OLD_EMAIL
|
||||
export CORRECT_EMAIL
|
||||
export CORRECT_NAME
|
||||
|
||||
git filter-branch --force --env-filter "${filter}" \
|
||||
--tag-name-filter cat -- --branches --tags
|
||||
}
|
||||
|
||||
|
||||
parse_options() {
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--all|-a)
|
||||
ALL=true
|
||||
shift
|
||||
;;
|
||||
--correct-email|-e)
|
||||
[[ -n "${2+x}" ]] || error 'Missing correct-email value'
|
||||
CORRECT_EMAIL="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--correct-name|-n)
|
||||
[[ -n "${2+x}" ]] || error 'Missing correct-name value'
|
||||
CORRECT_NAME="$2"
|
||||
shift 2
|
||||
;;
|
||||
--old-email|-o)
|
||||
[[ -n "${2+x}" ]] || error 'Missing old-email value'
|
||||
OLD_EMAIL="$2"
|
||||
shift 2
|
||||
;;
|
||||
--type|-t)
|
||||
[[ -n "${2+x}" ]] || error 'Missing type value'
|
||||
TYPE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--use-config|-c)
|
||||
CONFIG=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
error "invalid option '$1'"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if ${CONFIG}; then
|
||||
# use config values if not explicitly already defined
|
||||
[[ -n "${CORRECT_EMAIL+x}" ]] || CORRECT_EMAIL=$( git config user.email )
|
||||
[[ -n "${CORRECT_NAME+x}" ]] || CORRECT_NAME=$( git config user.name )
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
validate_options() {
|
||||
# Either OLD_EMAIL should be set or ALL should be true
|
||||
if [[ -z "${OLD_EMAIL+x}" ]] && ! ${ALL}; then
|
||||
msg="missing target of the rewrite"
|
||||
msg="${msg}\nuse either --old-email option or --all flag"
|
||||
error "${msg}"
|
||||
fi
|
||||
|
||||
# OLD_EMAIL shouldn't be set if ALL is true as well to prevent misuse
|
||||
if [[ -n "${OLD_EMAIL+x}" ]] && ${ALL}; then
|
||||
msg="ambiguous target of the rewrite"
|
||||
msg="${msg}\nuse either --old-email option or --all flag"
|
||||
error "${msg}"
|
||||
fi
|
||||
|
||||
# CORRECT_NAME should be either unset or set to non-empty string
|
||||
[[ -n "${CORRECT_NAME-x}" ]] || error "empty name is not allowed"
|
||||
|
||||
# Either CORRECT_EMAIL or CORRECT_NAME should be set
|
||||
if [[ -z "${CORRECT_EMAIL+x}" ]] && [[ -z "${CORRECT_NAME+x}" ]]; then
|
||||
msg="missing correct email and/or name to set"
|
||||
msg="${msg}\nuse --correct-email and/or --correct-name options"
|
||||
msg="${msg}\nor --use-config flag with user values set in Git config"
|
||||
error "${msg}"
|
||||
fi
|
||||
|
||||
# TYPE should be a valid identifier
|
||||
if [[ "${TYPE}" != 'both' ]] \
|
||||
&& [[ "${TYPE}" != 'author' ]] \
|
||||
&& [[ "${TYPE}" != 'committer' ]]; then
|
||||
error "invalid type '${TYPE}'"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
init_variables
|
||||
parse_options "$@"
|
||||
validate_options
|
||||
|
||||
reauthor
|
||||
|
|
@ -113,6 +113,19 @@ _git_psykorebase(){
|
|||
__gitcomp "$(__git_heads) --continue --no-ff"
|
||||
}
|
||||
|
||||
_git_reauthor(){
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local comp
|
||||
|
||||
if [[ "${prev}" == '--type' ]] || [[ "${prev}" == '-t' ]]; then
|
||||
comp='author committer full'
|
||||
else
|
||||
comp='--all --correct-email --correct-name --old-email --type --use-config'
|
||||
fi
|
||||
|
||||
__gitcomp "${comp}"
|
||||
}
|
||||
|
||||
_git_refactor(){
|
||||
__git_extras_workflow "refactor"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ git-extras(1) -- Awesome GIT utilities
|
|||
- **git-missing(1)** Show commits missing from another branch
|
||||
- **git-pr(1)** Checks out a pull request locally
|
||||
- **git-psykorebase(1)** Rebase a branch with a merge commit
|
||||
- **git-reauthor(1)** Rewrite history to change author's identity
|
||||
- **git-rebase-patch(1)** Rebases a patch
|
||||
- **git-refactor(1)** Create refactor branch
|
||||
- **git-release(1)** Commit, tag and push changes to the repository
|
||||
|
|
|
|||
198
man/git-reauthor.1
Normal file
198
man/git-reauthor.1
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-REAUTHOR" "1" "July 2016" "" ""
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBgit\-reauthor\fR \- Rewrite history to change author\'s identity
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
\fBgit reauthor [<options>]\fR
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
Lets you replace the author and/or committer identities in commits and tags\.
|
||||
.
|
||||
.P
|
||||
The command goes through all existing commits and tags in all local branches to selectively modify the identities present in those objects\. All the other informations such as dates, messages,\.\. are preserved\.
|
||||
.
|
||||
.P
|
||||
You can rewrite all the identities in the commits and tags objects by using the \-\-all flag, or only replace the identities whose email matches the value of the \-\-old\-email option\. It is also possible to limit the rewrite to a certain type of identity: the author or the committer identity\. By default, both of them are affected\.
|
||||
.
|
||||
.br
|
||||
For each of those identities to update, the command will replace the name and/or email with the new correct values as defined via the options\. If the new identity name to set is not defined, the current one will be kept (and vice\-versa with the email)\.
|
||||
.
|
||||
.P
|
||||
\fBWARNING!\fR This command rewrites history and as a result you will not able to push your branch to the remote without using the \-\-force option\.
|
||||
.
|
||||
.br
|
||||
See more information with \fBgit help filter\-branch\fR\.
|
||||
.
|
||||
.SH "OPTIONS"
|
||||
\-a, \-\-all
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Rewrite ALL identities in commits and tags\.
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
\-c, \-\-use\-config
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Define correct values from user Git config
|
||||
Values of \-\-correct\-email and \-\-correct\-name options take precedence over the ones from the config if specified as well
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
\-e, \-\-correct\-email <\fIemail\fR>
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Define the correct email to set
|
||||
Empty email \'\' is allowed
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
\-n, \-\-correct\-name <\fIname\fR>
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Define the correct name to set
|
||||
Empty name \'\' is not allowed
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
\-o, \-\-old\-email <\fIemail\fR>
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Rewrite identities matching old email in commits and tags
|
||||
Empty email \'\' is allowed
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
\-t, \-\-type <\fIid\fR>
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Define the type of identities affected by the rewrite
|
||||
Possible type identifiers are: author, committer, both (default)
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "EXAMPLES"
|
||||
Replace the personal email and name of Jack to his work ones
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git reauthor \-\-old\-email jack@perso\.me \-\-correct\-email jack@work\.com \-\-correct\-name \'Jack Foobar\'
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
Replace the email and name of Jack to the ones defined in the Git config
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git reauthor \-\-old\-email jack@perso\.me \-\-use\-config
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
Replace only the email of Jack (keep the name already used)
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git reauthor \-\-old\-email jack@perso \-\-correct\-email jack@perso\.me
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
Change only the committer email of Jack (keep the author email already used)
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git reauthor \-\-old\-email jack@perso\.me \-\-correct\-email jack@work\.com \-\-type committer
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
Set Jack\'s identity as the only one of the whole repository
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git reauthor \-\-all \-\-correct\-email jack@perso\.me \-\-correct\-name Jack
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
Set Jack as the only committer of the whole repository (keeps authors)
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git reauthor \-\-all \-\-correct\-email jack@perso\.me \-\-correct\-name Jack \-\-type committer
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "AUTHOR"
|
||||
Written by Damien Tardy\-Panis <\fIdamien@tardypad\.me\fR>
|
||||
.
|
||||
.SH "REPORTING BUGS"
|
||||
<\fIhttp://github\.com/tj/git\-extras/issues\fR>
|
||||
.
|
||||
.SH "SEE ALSO"
|
||||
<\fIhttps://github\.com/tj/git\-extras\fR>
|
||||
183
man/git-reauthor.html
Normal file
183
man/git-reauthor.html
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv='content-type' value='text/html;charset=utf8'>
|
||||
<meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
|
||||
<title>git-reauthor(1) - Rewrite history to change author's identity</title>
|
||||
<style type='text/css' media='all'>
|
||||
/* style: man */
|
||||
body#manpage {margin:0}
|
||||
.mp {max-width:100ex;padding:0 9ex 1ex 4ex}
|
||||
.mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
|
||||
.mp h2 {margin:10px 0 0 0}
|
||||
.mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
|
||||
.mp h3 {margin:0 0 0 4ex}
|
||||
.mp dt {margin:0;clear:left}
|
||||
.mp dt.flush {float:left;width:8ex}
|
||||
.mp dd {margin:0 0 0 9ex}
|
||||
.mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
|
||||
.mp pre {margin-bottom:20px}
|
||||
.mp pre+h2,.mp pre+h3 {margin-top:22px}
|
||||
.mp h2+pre,.mp h3+pre {margin-top:5px}
|
||||
.mp img {display:block;margin:auto}
|
||||
.mp h1.man-title {display:none}
|
||||
.mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
|
||||
.mp h2 {font-size:16px;line-height:1.25}
|
||||
.mp h1 {font-size:20px;line-height:2}
|
||||
.mp {text-align:justify;background:#fff}
|
||||
.mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
|
||||
.mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
|
||||
.mp u {text-decoration:underline}
|
||||
.mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
|
||||
.mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
|
||||
.mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
|
||||
.mp b.man-ref {font-weight:normal;color:#434241}
|
||||
.mp pre {padding:0 4ex}
|
||||
.mp pre code {font-weight:normal;color:#434241}
|
||||
.mp h2+pre,h3+pre {padding-left:0}
|
||||
ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
|
||||
ol.man-decor {width:100%}
|
||||
ol.man-decor li.tl {text-align:left}
|
||||
ol.man-decor li.tc {text-align:center;letter-spacing:4px}
|
||||
ol.man-decor li.tr {text-align:right;float:right}
|
||||
</style>
|
||||
</head>
|
||||
<!--
|
||||
The following styles are deprecated and will be removed at some point:
|
||||
div#man, div#man ol.man, div#man ol.head, div#man ol.man.
|
||||
|
||||
The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
|
||||
.man-navigation should be used instead.
|
||||
-->
|
||||
<body id='manpage'>
|
||||
<div class='mp' id='man'>
|
||||
|
||||
<div class='man-navigation' style='display:none'>
|
||||
<a href="#NAME">NAME</a>
|
||||
<a href="#SYNOPSIS">SYNOPSIS</a>
|
||||
<a href="#DESCRIPTION">DESCRIPTION</a>
|
||||
<a href="#OPTIONS">OPTIONS</a>
|
||||
<a href="#EXAMPLES">EXAMPLES</a>
|
||||
<a href="#AUTHOR">AUTHOR</a>
|
||||
<a href="#REPORTING-BUGS">REPORTING BUGS</a>
|
||||
<a href="#SEE-ALSO">SEE ALSO</a>
|
||||
</div>
|
||||
|
||||
<ol class='man-decor man-head man head'>
|
||||
<li class='tl'>git-reauthor(1)</li>
|
||||
<li class='tc'></li>
|
||||
<li class='tr'>git-reauthor(1)</li>
|
||||
</ol>
|
||||
|
||||
<h2 id="NAME">NAME</h2>
|
||||
<p class="man-name">
|
||||
<code>git-reauthor</code> - <span class="man-whatis">Rewrite history to change author's identity</span>
|
||||
</p>
|
||||
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p><code>git reauthor [<options>]</code></p>
|
||||
|
||||
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
||||
|
||||
<p>Lets you replace the author and/or committer identities in commits and tags.</p>
|
||||
|
||||
<p>The command goes through all existing commits and tags in all local branches to selectively modify the identities present in those objects. All the other informations such as dates, messages,.. are preserved.</p>
|
||||
|
||||
<p>You can rewrite all the identities in the commits and tags objects by using the --all flag, or only replace the identities whose email matches the value of the --old-email option. It is also possible to limit the rewrite to a certain type of identity: the author or the committer identity. By default, both of them are affected.<br />
|
||||
For each of those identities to update, the command will replace the name and/or email with the new correct values as defined via the options. If the new identity name to set is not defined, the current one will be kept (and vice-versa with the email).</p>
|
||||
|
||||
<p><code>WARNING!</code> This command rewrites history and as a result you will not able to push your branch to the remote without using the --force option.<br />
|
||||
See more information with <code>git help filter-branch</code>.</p>
|
||||
|
||||
<h2 id="OPTIONS">OPTIONS</h2>
|
||||
|
||||
<p> -a, --all</p>
|
||||
|
||||
<pre><code>Rewrite ALL identities in commits and tags.
|
||||
</code></pre>
|
||||
|
||||
<p> -c, --use-config</p>
|
||||
|
||||
<pre><code>Define correct values from user Git config
|
||||
Values of --correct-email and --correct-name options take precedence over the ones from the config if specified as well
|
||||
</code></pre>
|
||||
|
||||
<p> -e, --correct-email <<var>email</var>></p>
|
||||
|
||||
<pre><code>Define the correct email to set
|
||||
Empty email '' is allowed
|
||||
</code></pre>
|
||||
|
||||
<p> -n, --correct-name <<var>name</var>></p>
|
||||
|
||||
<pre><code>Define the correct name to set
|
||||
Empty name '' is not allowed
|
||||
</code></pre>
|
||||
|
||||
<p> -o, --old-email <<var>email</var>></p>
|
||||
|
||||
<pre><code>Rewrite identities matching old email in commits and tags
|
||||
Empty email '' is allowed
|
||||
</code></pre>
|
||||
|
||||
<p> -t, --type <<var>id</var>></p>
|
||||
|
||||
<pre><code>Define the type of identities affected by the rewrite
|
||||
Possible type identifiers are: author, committer, both (default)
|
||||
</code></pre>
|
||||
|
||||
<h2 id="EXAMPLES">EXAMPLES</h2>
|
||||
|
||||
<p>Replace the personal email and name of Jack to his work ones</p>
|
||||
|
||||
<pre><code>$ git reauthor --old-email jack@perso.me --correct-email jack@work.com --correct-name 'Jack Foobar'
|
||||
</code></pre>
|
||||
|
||||
<p>Replace the email and name of Jack to the ones defined in the Git config</p>
|
||||
|
||||
<pre><code>$ git reauthor --old-email jack@perso.me --use-config
|
||||
</code></pre>
|
||||
|
||||
<p>Replace only the email of Jack (keep the name already used)</p>
|
||||
|
||||
<pre><code>$ git reauthor --old-email jack@perso --correct-email jack@perso.me
|
||||
</code></pre>
|
||||
|
||||
<p>Change only the committer email of Jack (keep the author email already used)</p>
|
||||
|
||||
<pre><code>$ git reauthor --old-email jack@perso.me --correct-email jack@work.com --type committer
|
||||
</code></pre>
|
||||
|
||||
<p>Set Jack's identity as the only one of the whole repository</p>
|
||||
|
||||
<pre><code>$ git reauthor --all --correct-email jack@perso.me --correct-name Jack
|
||||
</code></pre>
|
||||
|
||||
<p>Set Jack as the only committer of the whole repository (keeps authors)</p>
|
||||
|
||||
<pre><code>$ git reauthor --all --correct-email jack@perso.me --correct-name Jack --type committer
|
||||
</code></pre>
|
||||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Damien Tardy-Panis <<a href="mailto:damien@tardypad.me" data-bare-link="true">damien@tardypad.me</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
<p><<a href="http://github.com/tj/git-extras/issues" data-bare-link="true">http://github.com/tj/git-extras/issues</a>></p>
|
||||
|
||||
<h2 id="SEE-ALSO">SEE ALSO</h2>
|
||||
|
||||
<p><<a href="https://github.com/tj/git-extras" data-bare-link="true">https://github.com/tj/git-extras</a>></p>
|
||||
|
||||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>July 2016</li>
|
||||
<li class='tr'>git-reauthor(1)</li>
|
||||
</ol>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
87
man/git-reauthor.md
Normal file
87
man/git-reauthor.md
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
git-reauthor(1) -- Rewrite history to change author's identity
|
||||
==============================================================
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
`git reauthor [<options>]`
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Lets you replace the author and/or committer identities in commits and tags.
|
||||
|
||||
The command goes through all existing commits and tags in all local branches to selectively modify the identities present in those objects. All the other informations such as dates, messages,.. are preserved.
|
||||
|
||||
You can rewrite all the identities in the commits and tags objects by using the --all flag, or only replace the identities whose email matches the value of the --old-email option. It is also possible to limit the rewrite to a certain type of identity: the author or the committer identity. By default, both of them are affected.
|
||||
For each of those identities to update, the command will replace the name and/or email with the new correct values as defined via the options. If the new identity name to set is not defined, the current one will be kept (and vice-versa with the email).
|
||||
|
||||
`WARNING!` This command rewrites history and as a result you will not able to push your branch to the remote without using the --force option.
|
||||
See more information with `git help filter-branch`.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
-a, --all
|
||||
|
||||
Rewrite ALL identities in commits and tags.
|
||||
|
||||
-c, --use-config
|
||||
|
||||
Define correct values from user Git config
|
||||
Values of --correct-email and --correct-name options take precedence over the ones from the config if specified as well
|
||||
|
||||
-e, --correct-email <<email>>
|
||||
|
||||
Define the correct email to set
|
||||
Empty email '' is allowed
|
||||
|
||||
-n, --correct-name <<name>>
|
||||
|
||||
Define the correct name to set
|
||||
Empty name '' is not allowed
|
||||
|
||||
-o, --old-email <<email>>
|
||||
|
||||
Rewrite identities matching old email in commits and tags
|
||||
Empty email '' is allowed
|
||||
|
||||
-t, --type <<id>>
|
||||
|
||||
Define the type of identities affected by the rewrite
|
||||
Possible type identifiers are: author, committer, both (default)
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
Replace the personal email and name of Jack to his work ones
|
||||
|
||||
$ git reauthor --old-email jack@perso.me --correct-email jack@work.com --correct-name 'Jack Foobar'
|
||||
|
||||
Replace the email and name of Jack to the ones defined in the Git config
|
||||
|
||||
$ git reauthor --old-email jack@perso.me --use-config
|
||||
|
||||
Replace only the email of Jack (keep the name already used)
|
||||
|
||||
$ git reauthor --old-email jack@perso --correct-email jack@perso.me
|
||||
|
||||
Change only the committer email of Jack (keep the author email already used)
|
||||
|
||||
$ git reauthor --old-email jack@perso.me --correct-email jack@work.com --type committer
|
||||
|
||||
Set Jack's identity as the only one of the whole repository
|
||||
|
||||
$ git reauthor --all --correct-email jack@perso.me --correct-name Jack
|
||||
|
||||
Set Jack as the only committer of the whole repository (keeps authors)
|
||||
|
||||
$ git reauthor --all --correct-email jack@perso.me --correct-name Jack --type committer
|
||||
|
||||
## AUTHOR
|
||||
|
||||
Written by Damien Tardy-Panis <<damien@tardypad.me>>
|
||||
|
||||
## REPORTING BUGS
|
||||
|
||||
<<http://github.com/tj/git-extras/issues>>
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
<<https://github.com/tj/git-extras>>
|
||||
|
|
@ -36,6 +36,7 @@ git-merge-repo(1) git-merge-repo
|
|||
git-missing(1) git-missing
|
||||
git-pr(1) git-pr
|
||||
git-psykorebase(1) git-psykorebase
|
||||
git-reauthor(1) git-reauthor
|
||||
git-rebase-patch(1) git-rebase-patch
|
||||
git-refactor(1) git-refactor
|
||||
git-release(1) git-release
|
||||
|
|
|
|||
Loading…
Reference in a new issue