CodeSkool

Editing the Author of Past Git Commits

Editing Past Commits Rewrites History!

NOTE: No matter how exactly we change the information of past commits, there’s one thing to always keep in mind: if we do this, we are effectively rewriting commit history.

This is nothing to take lightly: you will create new commit objects in this process, which can become a serious problem for your collaborators – because they might have already based new work on some of the original commits.

Therefore, think twice before you rewrite your commit history!

In a nutshell these are the commands to be executed for changing the author information of a previous Git commit.

git log
git rebase -i [COMMIT_HASH_OF_PREVIOUS_COMMIT_TO_THE_ONE_YOU_WANT_TO_EDIT]
# Change the commit you want to edit from "pick" to "edit"
git commit --amend --author="Code Skool <support@codeskool.cc>" --no-edit
git rebase --continue
git push --force-with-lease --progress  -- "origin" main:main

For more information please refer to: https://www.git-tower.com/learn/git/faq/change-author-name-email

Leave a Reply

Your email address will not be published. Required fields are marked *