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

Re: OK, how should I have done this...

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 23, 2010, 00:05 UTC
Message-ID
<7vr5ecvr9p.fsf@alter.siamese.dyndns.org>
In-Reply-To
<AANLkTim0_J0i_a0o+z1oCC4mramfUxCGtCg_Y+ab+h+-@mail.gmail.com>
Patrick Doyle <wpdster@gmail.com> writes:
> But I _know_ that there must be a better way to do this.  What should
> I have done?

Depends on how you wanted to fix your history (we already know from your description what shape of tree you want to end up in).

If you want to pretend that you were perfect and never made mistakes in these three files you had to fix later, then history surgery like what Matthieu suggested would be necessary (I won't repeat how).

On the other hand, if you want to record what you did in the time order, then I would probably do this:

 $ git checkout master ; test ;# broken
 $ git checkout 5ccce3 ; test ;# ok
 $ git checkout master -- file1 ; test ;# ok
 $ git checkout master -- file2 ; test ;# ok
 $ git checkout master -- blah/file7 ; test ;# broken
 $ edit blah/file7 ; test ;# ok
 $ git reset --soft master
 $ git commit -a -m 'The change to file3 was borked on the other env' -e

and in this particular case, this would be what I would have done, as a separate "fix-up" commit will give me a place to describe why a solution different from the initial attempt, which was Ok on the original machine, was necessary.

 
Previous: Matthieu MoyNext: Patrick Doyle
Message 6 of 7 in “OK, how should I have done this...”
  1. Patrick DoyleNov 22, 2010
  2. Matthieu MoyNov 22, 2010
  3. Patrick DoyleNov 22, 2010
  4. Tay Ray ChuanNov 22, 2010
  5. Matthieu MoyNov 22, 2010
  6. Junio C HamanoNov 23, 2010
  7. Patrick DoyleNov 23, 2010

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.