不常见操作的备忘
1. 查看当前的提交信息
# 列出 hash / 用户名 / 邮箱
git log --pretty=format:"%h %an %ae"
2. 使用如下
shell
# 将 [email protected] 替换为步骤 1 的邮箱
# 将 [email protected] 替换为你的新邮箱
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
NEW_NAME="yournewname"
NEW_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$NEW_NAME"
export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
3. 覆盖远程
git push origin --force --all
git push origin --force --tags
Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f
解决方案
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD