Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This is a related question to How do I edit git’s history to correct an incorrect email address/name. Using git rebase -i <first commit>, git commit --amend --author "Foo <foo@example.com>", and git rebase --continue, I was able to fix the logs for all of the commits but the first one. How do I fix the first commit?

share|improve this question

1 Answer 1

up vote 12 down vote accepted

After much trial and error, the following recipe was found to work:

# tag the root-most commit so we can reference it
git tag root `git rev-list HEAD | tail -1`
# check it out on its own branch
git checkout -b new-root root
# amend the commit
git commit --amend
# now you've changed the commit message, so checkout the original branch again
git checkout @{-1}
# and rebase it onto your new root commit
git rebase --onto new-root root
# then nuke the temporary branch and tag we created
git branch -d new-root
git tag -d root

true credit should go to drizzd on #git for this answer.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.