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

Re: Unexpected behaviour with git stash save --keep-index?

From
Karl Hasselström <kha@treskal.com>
Date
Sep 2, 2008, 07:45 UTC
Message-ID
<20080902074516.GA5402@diana.vm.bytemark.co.uk>
In-Reply-To
<B1185033-36D7-4504-92A3-6F75B6CE90DF@gmail.com>
On 2008-09-02 01:14:10 +0200, Jonas Flodén wrote:
> while I was using StGit for the first time
[...]
> Also maybe someone could someone recommend a way to split an unclean
> working dir into several patches/commits?
This is what I usually do:
  1. Create a new StGit patch with all the changes.
  2. Pop that patch.
  3. View the patch in an emacs diff-mode buffer, and repeatedly
       a. apply one or more hunks, and
       b. create a new patch with just those changes
     until no more changes remain.
Another way to do it would be to
  1. Use e.g. git-gui to stage the changes you want in your first
     patch.
  2. Make an StGit patch out of just that (with e.g. stg new and stg
     refresh --index).
  3. If the worktree is still dirty, go to step 1.

A third method I usually make use of is to commit very often while developing, and periodically clump these microcommits together into larger commits. This sidesteps the whole problem of splitting up a commit into pieces, which can be quite a chore if splitting on hunk boundaries isn't enough. (stg coalesce will turn two or more smaller patches into one large patch for you. And I'm pretty sure git-rebase --interactive has some equivalent functions.)

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
Previous: Jonas Flodén
Message 6 of 6 in “Unexpected behaviour with git stash save --keep-index?”
  1. Jonas FlodénSep 1, 2008
  2. SZEDER GáborSep 2, 2008
  3. Documentation: fix disappeared lines in 'git stash' manpageSZEDER Gábor, Sep 2, 2008
  4. Documentation: minor cleanup in a use case in 'git stash' manualSZEDER Gábor, Sep 2, 2008
  5. Jonas FlodénSep 2, 2008
  6. Karl HasselströmSep 2, 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.