E
E
ettaluni2021-08-29 17:42:05
git
ettaluni, 2021-08-29 17:42:05

How to undo a commit and revert data?

Made a wrong commit, did not add files did a hard reset back added files made a commit again. But the git at the first reset operation returned everything back and I made a new commit with the old data.
I can't find where my commit was now git reset --hard [email protected]{1} but I can't find the files - they are now empty.
How do I get back to that commit point when I forgot to add the files?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
toxa82, 2021-08-29
@ettaluni

I didn’t quite understand what you were doing there and why it was necessary to use --hard. But if you commit the changes, they remain. After a hard reset, they most likely are no longer attached to anything and hang in anticipation of garbage collection. My solution does not pretend to be the only correct one, but you can try.
1) Use git reflog --date=iso -20 to list where HEAD was at a specific time and find your desired commits.
2) Using the git cherry-pick command, apply the specified commits on the desired branch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question