git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: On undoing a forced push

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jun 9, 2015, 13:17 UTC
Message-ID
<vpqtwuh6my1.fsf@anie.imag.fr>
In-Reply-To
<20150609121221.GA14126@lanh>
Duy Nguyen <pclouds@gmail.com> writes:
Show 5 quoted lines
> From a thread on Hacker News. It seems that if a user does not have
> access to the remote's reflog and accidentally forces a push to a ref,
> how does he recover it? In order to force push again to revert it
> back, he would need to know the remote's old SHA-1. Local reflog does
> not help because remote refs are not updated during a push.

More precisely, the remote-tracking ref is updated, and so is its reflog, but the reflog entry usually does not help, because it documents the old and new sha1 of the remote-tracking ref, not of the remote ref itself. Typically, if a coworker pushed some code that I did not pull, and I force-push to the same branch, my reflog won't have the sha1 of my coworker's code.

> This patch prints the latest SHA-1 before the forced push in full.
Sounds like a good idea to me.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Duy NguyenNext: Sitaram Chamarty
Message 2 of 11 in “On undoing a forced push”
  1. Duy NguyenJun 9, 2015
  2. Matthieu MoyJun 9, 2015
  3. Sitaram ChamartyJun 9, 2015
  4. Jeff KingJun 9, 2015
  5. Sitaram ChamartyJun 9, 2015
  6. Johannes SchindelinJun 9, 2015
  7. Stefan BellerJun 9, 2015
  8. Duy NguyenJun 9, 2015
  9. brian m. carlsonJun 9, 2015
  10. Duy NguyenJun 10, 2015
  11. brian m. carlsonJun 10, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.