News for hackers. Stuff that matters.
Re:How to undo almost anything with Git by dsp1234 on Monday June 08, 2015 @03:57PM (#9681918)
Git generally doesn't delete commits until a garbage collection is done (and assuming no other references). If you find yourself in this situation again, then try:

git reflog show remotes/origin/develop

This will show the reflog for the branch, then you can find the hash just before your push, check it out, then force push it back.

I've recovered from other developer's accidental force pushes in less than 5 minutes, with no commits lost.

Re:How to undo almost anything with Git by jordigh on Monday June 08, 2015 @04:11PM (#9682032)
But if the remote has advanced since you pushed, you'll still need to reflog on the remote server, right?
Re:How to undo almost anything with Git by lmm on Monday June 08, 2015 @04:20PM (#9682101)
Someone must have pushed the version the remote was at, so the correct commit would be on someone's devbox.
Re:How to undo almost anything with Git by mmanfrin on Monday June 08, 2015 @04:40PM (#9682227)
It was a series of PRs merged on github, no one in the office had a current branch of develop.
Re:How to undo almost anything with Git by dsp1234 on Monday June 08, 2015 @05:08PM (#9682427)
It looks like you can use the GitHub API to get the events for the specific repo, which would include your force push, and the hash of the previous commit. Some instructions at https://objectpartners.com/2014/02/11/recovering-a-commit-fr...

edit: This should be in reply to jordigh's comment above

Re:How to undo almost anything with Git by lmm on Tuesday June 09, 2015 @05:48AM (#9684869)
If it's just a matter of "merging" couldn't you just merge those branches again? Or do you resolve conflicts on github or some such (something that's never fit my workflow but I can imagine others using it)?
Re:How to undo almost anything with Git by erikb on Tuesday June 09, 2015 @04:21AM (#9684609)
That's really the point. The guy who made the last change should have it locally as well. Even if he git pulls first.
Re:How to undo almost anything with Git by bicolao on Monday June 08, 2015 @07:14PM (#9683110)
During any push, the remote advertises latest SHA-1. I don't know if we actually use it in 'push -f'. But if we haven't, it's a good idea to save this in local reflog.