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

Re: Newbie falls at first hurdle

From
Junio C Hamano <junkio@cox.net>
Date
Sep 18, 2005, 20:10 UTC
Message-ID
<7vfys22l3k.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<200509182011.10689.alan@chandlerfamily.org.uk>
Alan Chandler <alan@chandlerfamily.org.uk> writes:
Show 7 quoted lines
> I effectively loaded both my current code and the day before's
> backup into git as two separate branches.
>
> What I was then trying to do, via various attempts with git diff -p was to 
> extract small chunks of updates (ie limit scope over a few files).  Edit the 
> result to limit the diff to cover a small update and then apply it to a my 
> current stuff to slowly undo some of the mess that I had made. 

Ah, what you have to work with are only date-based snapshots of various states (i.e. the separation between one snapshot and another does not necessarily have much to do with a single set of logically isolated changes).

I end up doing that myself, although the situation I'd be in tend to be one logical change spread over multiple commits (the other way around from your case where one diff contains many logically unrelated chagnes). I run git-diff-tree -p between states to obtain a set of N diffs, look them over and hand edit them to collect related things together and separate independent things separate to create a different set of M diffs. then create a temporary branch that is reset to the state before those N diffs and use applymbox to apply M diffs. This is essentially what Martin suggested.

In your case, each diff you have contains unrelated changes and you have to move things around. It's a pain but I am afraid there are not any SCM can do much to help you.

Previous: Alan ChandlerNext: Sven Verdoolaege
Message 8 of 13 in “Re: Newbie falls at first hurdle”
  1. Horst von BrandSep 18, 2005
  2. Martin LanghoffSep 18, 2005
  3. Alan ChandlerSep 18, 2005
  4. Junio C HamanoSep 18, 2005
  5. Linus TorvaldsSep 18, 2005
  6. Junio C HamanoSep 18, 2005
  7. Alan ChandlerSep 18, 2005
  8. Junio C HamanoSep 18, 2005
  9. Sven VerdoolaegeSep 19, 2005
  10. Martin LanghoffSep 18, 2005
  11. Horst von BrandOct 3, 2005
  12. Horst H. von BrandJan 13, 2007
  13. Shawn O. PearceJan 13, 2007

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.