forked from scottso/misc-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit_fix_author.sh
More file actions
executable file
·36 lines (31 loc) · 866 Bytes
/
git_fix_author.sh
File metadata and controls
executable file
·36 lines (31 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#/bin/bash
# This will go through a repo history and replace
# username and email with a new username and email
# in the logs. This is handy if someone commits
# and pushes without having their user.name and
# user.email set.
if [ -z ${1} ] || [ -z ${2} || [ -z ${3} || [ -z ${4} ];
then
echo
echo "Usage: ${0} 'Old Username' 'Old E-mail' 'New Username' 'New Email'"
echo
fi
exit 1
git filter-branch --env-filter '
if [ "$GIT_AUTHOR_EMAIL" = "${2}" ];
then
export GIT_AUTHOR_EMAIL="${4}";
fi
if [ "$GIT_COMMITTER_EMAIL" = "${2}" ];
then
export GIT_COMMITTER_EMAIL="${4}";
fi
if [ "$GIT_AUTHOR_NAME" = "${1}" ];
then
export GIT_AUTHOR_NAME="${3}"
fi
if [ "$GIT_COMMITTER_NAME" = "${1}" ];
then
export GIT_COMMITTER_NAME="${3}"
fi
' HEAD