Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo a Git rollback

I wanted to rollback to the last commit after making a massive error, but I managed to rollback a little too fair. The commit I wanted to reassert doesn't appear when I enter 'git log' in bash (I suppose because it's no longer in the history). Is there any way I can recover the last commit by date?

I'm also using eGit in eclipse for the same project if that makes things easier. Thanks.

like image 370
Chironex Avatar asked Jul 06 '11 16:07

Chironex


People also ask

How do I undo a git rollback?

You would also be able to do git reset --hard HEAD@{1} and then come back to egit and rollback to the desired commit. Show activity on this post. I find that generally it's better to make your changes forward in time rather than backward. Git's approach is to "revert" the commit.

Can you rollback undo a commit?

To undo changes associated with a specific commit, developers should use the git revert command. To undo every change that has happened since a given commit occurred, use git reset.

Can I undo git checkout?

Challenge - use git reset then checkout to undo changes Save your changes (if you're in a text editor). Use git add to stage your changes to the README.md file. Undo the commit that you made using git reset . Then revert back to the previously committed version using git reset .


1 Answers

If you are ok with command line, go to you repo, do a git reflog and get the commit which you want to "rollback" to and do a git reset --hard <commit>

You would also be able to do git reset --hard HEAD@{1} and then come back to egit and rollback to the desired commit.

like image 55
manojlds Avatar answered Oct 15 '22 01:10

manojlds