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

Re: [PATCH] add commit --interactive

From
David Kågedal <davidk@lysator.liu.se>
Date
Mar 2, 2007, 12:47 UTC
Message-ID
<87hct3zuay.fsf@morpheus.local>
In-Reply-To
<7v649ki3h1.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 5 quoted lines
> Probably the operation would go like this.  I'll describe them
> in terms of lower level operations, and leave the scripting to
> others.
>
> * Stashing the current state
[...]
> * Switch to the commit you want to apply part of what was
[...]
> * Trickle some of the stashed changes in, perhaps interactively:
[...]
> * Review and test the change in the working tree.  This does not
[...]
> * Then this is the tricky and interesting part.  We need to
>   subtract the change we already used to advance HEAD from
>   "stashed changes".  I do not think we currently have a single
>   command to do this step, but it would probably go like this.

What I would want to do here is to simply restore the original "stash" tree, so something like "git checkout stash -- ." would probably work.

The reason is that what I would consider a common scenario is that I realize that some of the changes I made should be commited first, and I extract them the way you describe, and maybe update them to erase traces of things I don't want to commit, perhaps on the same source lines.

But then I want to continue where I was, and reintroduce the things I cleaned away in the previous step.

This is also much simpler to do. So let's make two scripts "git-stash" and "git-unstash"

    # git-stash:
    git-commit -m "temporary stash"
    git-tag stash
    git-reset --hard HEAD^
    # git-unstash:
    git-checkout stash -- .
    # or possibly:
    #current=$(git-rev-parse HEAD)
    #git-checkout stash
    #git-reset --mixed $current
    git-tag -d stash
Then I would do this:
  [ ... hack hack ... ]
  $ git stash
  $ git pick stash
  [ ... cleanup ... ]
  $ git commit -a -m "first change"
  $ git unstash
-- 
David Kågedal
Previous: Junio C Hamano
Message 3 of 3 in “add commit --interactive”
  1. add commit --interactivePaolo Bonzini, Mar 1, 2007
  2. Junio C HamanoMar 2, 2007
  3. David KågedalMar 2, 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.