Skip to content

Instantly share code, notes, and snippets.

@David-Lor
Last active November 11, 2019 19:18
Show Gist options
  • Save David-Lor/b7f19107d4c6a521df69815f2a6e0520 to your computer and use it in GitHub Desktop.
Save David-Lor/b7f19107d4c6a521df69815f2a6e0520 to your computer and use it in GitHub Desktop.
Git - Rewrite history with current (global) user & email
#!/bin/bash
set -ex
NAME="$(git config --global --get user.name)"
EMAIL="$(git config --global --get user.email)"
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='${NAME}'; GIT_AUTHOR_EMAIL='${EMAIL}'; GIT_COMMITTER_NAME='${NAME}'; GIT_COMMITTER_EMAIL='${EMAIL}';" HEAD
echo "Now run \"git push --force\" to override commits on remote repository"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment