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?
Asked
Active
Viewed 29 times
0

fatpanda2049
- 483
- 1
- 4
- 9
-
Can you detail certain commits ? Are we speaking about a couple or a long list ? – Ôrel Mar 23 '23 at 15:17
-
https://stackoverflow.com/search?q=%5Bgit%5D+undo+filter-branch – phd Mar 23 '23 at 15:53
2 Answers
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