It will be problematic if everybody has pushed to the same branch, because rewriting your local history with right username/email will imply a git push --force
, meaning that will change the SHA1 of commits on the remote repository side.
If you have push in a separate branch however, you can force push without much consequence beside alerting the professor and make sure the script will consider your newly written branch.
Check if there is really no email associated to your last commit with:
git log --format='%ae' HEAD
The OP ddipi confirm in the comments:
I used the git log --format='%ae' HEAD
command to find out that I actually was using my old email address.
I added it to my Github account and the problem was solved.
For resetting user/email on commits, I would recommend this days to use the new tool git filter-repo
, which replaces BFG and git filter-branch
.
See its user manual.
To modify username and emails of commits, you can create a mailmap file in the format accepted by git-shortlog
.
For example, if you have a file named my-mailmap you can run
git filter-repo --mailmap my-mailmap
and if the current contents of that file are as follows (if the specified mailmap file is version controlled, historical versions of the file are ignored):
Correct Name <correct@email.com> <old@email.com>
then we can update username and/or emails based on the specified mapping.
See git shortlog
"mapping author" section for the exact syntax of a mailmap file.
Or, with callbacks:
git-filter-repo --name-callback 'return name.replace(b"OldName", b"NewName")' \
--email-callback 'return email.replace(b"old@email.com", b"new@email.com")'