Git使用技巧

一、分支管理

二、提交日志管理

  • 批量替换历史提交日志的用户名和邮箱信息
git filter-branch -f --env-filter '
OLD_NAME="old_name"
OLD_EMAIL="old@mail.com"
CORRECT_NAME="new_name"
CORRECT_EMAIL="new@mail.com"
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

三、用户管理

Author: bugwz
Link: https://bugwz.com/2019/10/10/git-skill/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.