سؤال

I have accidently done a reverse commit of a branch on which I was working on. Is there any way to undo that reverse commit and get my changes back?

هل كانت مفيدة؟

المحلول

This is the answer you're looking for.

It shows how to find your committed files in history and reset to them.

نصائح أخرى

If you reseted the head of your branch than you need the old head's sha1. Maybe you can find it in the .git/objects directory by date. (try git show xyz with the suspicious sha's. (suspicious means the modification time can match.))

If you commited a "reverse" commit, than you have to repeat only what you did. (commit an other reverse commit.) Or you can also reset the head to remove the "reverse" commit from your branch's history. (git reset --soft 'HEAD^')

There are a few helpful description: How to undo last commit(s) in Git?

If you get the SHA of the original commit (the one you later reversed) you can cherry-pick that one back to HEAD.

Or you can just reverse the reverse. It will basically be the same thing.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top