Reputation: 23
I was changing the git author information inside the terminal and for whatever reason the update has removed the email from the commit and now I am unable to revert this change and can't add an email address to this commit.
The commit includes an author that I can't amend and the email linked to the commit is <>.
Can someone please advise how I can add an email address to this author?
Upvotes: 0
Views: 308
Reputation: 5214
You can batch change the commit history with the nuclear option git filter-branch
. Using --env-filter
, you can change author and email info. See Changing Author Info - GitHub for more info. Since you don't have an email info now, you may catch the messy name for judging the necessity of rewriting.
For example,
#!/bin/sh
git filter-branch -f --env-filter '
OLD_NAME="Your messy name" # you may need to escape the " char in the head and tail of that messy
CORRECT_NAME="MatthewLRichardson"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_NAME" = "#OLD_NAME" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_NAME" = "#OLD_NAME" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
Then, do a force push, and tell your collaborator to update their fork, if there exists some.
Upvotes: 1