0

I was planning to change some commits' usernames and emails in git log. Following this answer, it changes all commits' username and emails, while I only want to modify certain commits. I am wondering how can I revert this change?

fatpanda2049
  • 483
  • 1
  • 4
  • 9

2 Answers2

1

git filter-branch has helpfully made a backup of the references that it has rewritten in the refs/original hierarchy.

Say, you have a branch main (that HEAD was pointing to before the operation). The full name is actually refs/heads/main. You will now find the backup under refs/original/refs/heads/main. To undo the branch you can simply do this:

git branch -f main refs/original/refs/heads/main
j6t
  • 9,150
  • 1
  • 15
  • 35
0

If you only ran git filter-branch once on your branch, you can reset it to its original head:

git reset refs/original/refs/heads/<branchname>
Jay
  • 3,640
  • 12
  • 17