1. Prevent them
2. Fix them
3. Minimize damage from them
4. Hide them
git push --force
if git settings contain push.default=matching
push.default=simple
git push --force origin feature-branch
git config user.name/user.email
git config
git config user.name "$(id -F)"
git config user.email "$(id -un)@$(hostname)"
Mik <dev@lightstar.local>
git config
: AWS
git log --format="%h %an <%ae>" -n 5
f14246a Ubuntu <ubuntu@ip-192-168-1-13.ec2.internal>
fa2b394 Ubuntu <ubuntu@ip-192-168-1-17.ec2.internal>
da23946 Ubuntu <ubuntu@ip-192-168-1-18.ec2.internal>
4098403 Ubuntu <ubuntu@ip-192-168-1-21.ec2.internal>
e3f335d Ubuntu <ubuntu@ip-192-168-1-22.ec2.internal>
git log --format="%h %an <%ae>" -n 5 --abbrev=4
b323 Mik <dev@lightstar.local>
1746 Nikolay Saskovets <>
0825 Mikalai Saskavets <>
71f4 Mikalai Saskavets <>
340c Mikalai Saskavets <>
git log --format="%h %an <%ae>" -n 5
3ba40cd Aleh Kogot <aleh@example.com>
323ba44 Aleh Kogot <aleh@example.com>
8258534 Alena Kogot <alena@mail.ru>
b323833 Aleh Kogot <aleh@example.com>
40cd7e2 Aleh Kogot <aleh@example.com>
[user]
name =
email =
git commit -m MESSAGE
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <>) not allowed
git commit -m MESSAGE
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <>) not allowed
git config user.email "you@example.com"
git config user.name "Your Name"
[user]
name =
email =
if f"{author.name} <{author.email}>" not in WHITELIST:
exit(1)
git config user.email "you@example.com"
git config user.name "Your Name"
git commit --amend --reset-author
git rebase -i -p a8d2013 # <-- hash of the last good commit
# ... mark all needed commits as "edit"
# ... then ... on each commit:
git commit --amend --author "Bo <bo@co.mp>" --no-edit
git rebase --continue
git commit --author
!git commit --amend --author "Bo <bo@co.mp>"
>>> git log --format=fuller
commit e7ea301 (HEAD -> master)
Author: Bo <bo@co.mp>
AuthorDate: Mon Jan 13 14:25:13 2020 +0300
Commit: Mikalai Saskavets <>
CommitDate: Tue Jan 28 12:39:31 2020 +0300
Пример тестового коммита
git rebase -i -p a8d2013 # <-- hash of the last good commit
# ... mark all needed commits as "edit"
# ... then ... on each commit:
git \
-c user.name="Bo" \
-c user.email=<bo@co.mp> \
commit --amend \
--reset-author --no-edit
git rebase --continue
git filter-branch --env-filter '
OLD_EMAIL=""
CORRECT_NAME="Bo"
CORRECT_EMAIL="bo@co.mp"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
git filter-branch --env-filter '
some shell magick here
' --tag-name-filter cat -- --branches --tags
# some shell magick:
OLD_EMAIL=""
CORRECT_NAME="Bo"
CORRECT_EMAIL="bo@co.mp"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
git-rocket-filter --branch master -f --commit-filter '
if (commit.AuthorName.Contains("Mikalai")) {
commit.AuthorName = "Bo";
commit.AuthorEmail = "bo@co.mp";
}
'
... but only one branch per launch
git rm DUMP.SQL
git rm DUMP.SQL
git rebase -i $(magick DUMP.SQL)
git rm DUMP.SQL
git rebase -i \
$(
git log --format="%h" \
--follow --diff-filter=A \
-- DUMP.SQL
)
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch DUMP.SQL' \
--prune-empty --tag-name-filter cat -- --all
git fetch --all --tags;
git reset origin --hard;
git branch -D $(git branch|grep -v '*');
git clean -x -d -f;