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

Re: About detached heads

From
David Kågedal <davidk@lysator.liu.se>
Date
Mar 14, 2008, 10:39 UTC
Message-ID
<87iqzpfv3l.fsf@lysator.liu.se>
In-Reply-To
<57518fd10803140251v425a0fa3ud11687a5043806cc@mail.gmail.com>
"Jonathan del Strother" <maillist@steelskies.com> writes:
Show 24 quoted lines
> On Fri, Mar 14, 2008 at 9:46 AM, Geoff Russell
> <geoffrey.russell@gmail.com> wrote:
>> This should be simple! I have a series of commits:
>>
>>            1---2---3---4---5
>>
>>  I want to go back to 3 but not branch, so I want
>>
>>            1---2---3---4---5---3
>>
>>  ?
>>
>>          git checkout 3...
>>
>>  gets me the commit on a detached head, but I don't know how to put this back
>>  as the HEAD.
>
>
> Two options.  Either rewrite history, nuking commits 4 & 5 :
>   git reset --hard 3
>
> or publicly reverse the changes introduced by 5 & 4 :
>   git revert 5
>   git revert 4
The revert can be done by resetting to the tree in 3:
  git checkout 3 -- .
  git commit -m "reset to 3"
-- 
David Kågedal
Previous: Jonathan del StrotherNext: Wincent Colaiuta
Message 3 of 22 in “About detached heads”
  1. Geoff RussellMar 14, 2008
  2. Jonathan del StrotherMar 14, 2008
  3. David KågedalMar 14, 2008
  4. Wincent ColaiutaMar 14, 2008
  5. Matthieu MoyMar 14, 2008
  6. Wincent ColaiutaMar 14, 2008
  7. Jakub NarebskiMar 14, 2008
  8. Sergei OrganovMar 14, 2008
  9. Adam PiatyszekMar 14, 2008
  10. Chris ShoemakerMar 14, 2008
  11. Rafael Garcia-SuarezMar 14, 2008
  12. Nicolas PitreMar 14, 2008
  13. Jakub NarebskiMar 14, 2008
  14. Linus TorvaldsMar 14, 2008
  15. Björn SteinbrinkMar 14, 2008
  16. Linus TorvaldsMar 14, 2008
  17. Jakub NarebskiMar 14, 2008
  18. SeanMar 14, 2008
  19. Geoff RussellMar 14, 2008
  20. Jakub NarebskiMar 15, 2008
  21. Nicolas PitreMar 15, 2008
  22. Geoff RussellMar 15, 2008

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.