Recovering Lost Commits After Push

I could use some help with a recovery strategy. Somehow we ended up in a position where one commit dropped about 3 days worth of commits. And then got pushed. The committer isn't sure whether he did forced the push or what, but now we're in this position. And about 10 additional commits have been pushed since the "bad" one.

All of the old commits are there and I could piece everything back together, but I'm hoping that Git can help me out. I suppose I could cherry-pick the range of commits between point A and point B, but is there anything better? Most, but not all, of the changes are local to one directory and I'd rather not manually inspect each one.

What's the right approach here remembering that everything has been pushed upstream?

Answers


git reset --hard <one commit before the bad commit>
git cherry-pick <the range of commits you've lost>
git pull

This way you simulate that you are on the last good commit (with the reset). Then you create new commits locally (cherry-pick). Now you pull in changes (and maybe merge conflicts).


Need Your Help

Which EJB 3 persisent provider should I use?

java orm jpa java-ee

I are using EJB 3 on a fairly large J2EE project, by default with Netbeans sets the persistent provider for the entity beans to TopLink. There is the option to change the provider to one of the fol...

Sinatra pass variables to erb

ruby sinatra

There's two ways I can do this.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.