From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: Robert Anderson <rwa000@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: An alternate model for preparing partial commits
Date: Fri, 27 Jun 2008 09:10:14 +0200 [thread overview]
Message-ID: <20080627071014.GA12344@atjola.homenet> (raw)
In-Reply-To: <9af502e50806262350t6e794a92g7751147f1882965@mail.gmail.com>
On 2008.06.26 23:50:06 -0700, Robert Anderson wrote:
> Seems to me the concept of the "index" is a half-baked version of what
> I really want, which is the ability to factor a working tree's changes
> into its constituent parts in preparation for committing them. The
> index provides some very nice facilities to factor out changes in a
> working tree into a "staging area", but the fundamental flaw of this
> in my view is that this "staging area" is not instantiated as a tree,
> so it cannot be compiled and/or tested before committing.
>
> Consider a facility where the state you want to commit next is built
> up in the current working directory, and the original set of changes
> exists in some proto-space like the index currently inhabits, where
> you can query and manipulate that state, but it isn't instantiated in
> your working tree.
>
> Imagine a session like this:
>
> You've got a couple of conflated changes in your working tree, that
> you think you can break up into two orthogonal changes, each of which
> will compile and pass a set of tests you've got. You think. You'd
> like to verify the build and test before you commit each piece.
>
> git prep
>
> where "prep" means "prepare commit". Don't get hung up on command or
> option names I'm using as placeholders, I just made that up without
> much deep thought about what to call it.
>
> Now my tree appears clean (and git diff returns nothing). I can now
> start adding the changes I had in my working tree that I want to
> include in the next commit, using git add (which would know I am in
> the "prep" mode). I can examine those original working dir changes I
> am choosing from with:
>
> git diff --prep
>
> which, at this point, shows the same output that "git diff" did before
> I ran "git prep." Now I want to add some subset of my original
> changes:
>
> git add newfile.c
> git add -i
> <add a couple of hunks of the changes from file modfile.c>
>
> Now I have a working tree state that I think I want to commit. I can
> examine it with:
>
> git diff
>
> and I can compile and test it. Yep, it works and passes my test suite
> (an option I did not have if I had added these changes to the index).
> So now I want to commit:
>
> git commit -a -m "made change A"
>
> I think the commit should probably "pop" the rest of the changes I did
> not commit back into the working directory. If I want to pull another
> subset of changes again, I can repeat the process with another "git
> prep".
>
> Does this idea resonate with anyone else?
Hm, I use "stash" for that purpose, which leads to kind of the reverse
of your approach. So I do sth. like this:
- hack hack hack
- Notice that I want to make two commits out of what I have in my
working tree
- git add -p -- stage what I want in the first commit
- git commit -m tmp -- temporary commit
- git stash -- stash away what doesn't belong in the first commit
- git reset HEAD^ -- drop the temporary commit, with the changes kept
in the working tree
- test, fix bugs, read the diff, whatever
- git commit -- this time for good
- git stash apply -- get back the changes for the second commit
Instead of using reset, you could also use "commit --amend" (I actually
used to do that), but that needs you to do "git diff HEAD^" to see the
full changes, and (IMHO) makes it a harder sometimes to review your
stuff, because you now have three places where the changes for one
commit might reside (HEAD, index and working tree).
Björn
next prev parent reply other threads:[~2008-06-27 7:11 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <willow-jeske-01l7H4tHFEDjCgPV-01l7H4sOFEDjCbyi>
2008-06-27 6:50 ` An alternate model for preparing partial commits Robert Anderson
2008-06-27 7:10 ` Björn Steinbrink [this message]
2008-06-27 14:37 ` [PATCH/RFC] stash: introduce 'stash save --keep-index' option SZEDER Gábor
2008-06-27 18:26 ` Junio C Hamano
2008-06-27 16:54 ` An alternate model for preparing partial commits Robert Anderson
2008-06-27 17:27 ` Björn Steinbrink
2008-06-27 17:34 ` Robert Anderson
2008-06-27 8:35 ` Johannes Sixt
2008-06-27 17:01 ` Robert Anderson
2008-06-27 8:50 ` Petr Baudis
2008-06-27 17:02 ` Robert Anderson
2008-06-27 13:33 ` Johannes Schindelin
2008-06-27 13:49 ` Miklos Vajna
2008-06-27 17:14 ` Robert Anderson
2008-06-27 17:45 ` Johannes Schindelin
2008-06-27 17:49 ` Robert Anderson
[not found] ` <alpine.DEB.1.00.0806271854120.9925@racer>
2008-06-27 18:07 ` Robert Anderson
2008-06-27 18:20 ` Dana How
2008-06-27 20:31 ` Stephen Sinclair
2008-06-27 20:45 ` David Jeske
2008-06-27 20:45 ` David Jeske
2008-06-28 17:23 ` Wincent Colaiuta
2008-06-28 2:14 ` Dmitry Potapov
2008-06-28 2:57 ` Robert Anderson
2008-06-28 4:03 ` Dmitry Potapov
[not found] ` <9af502e50806272320p23f01e8eo4a67c5f6f4476098@mail.gmail.com>
2008-06-28 6:31 ` Fwd: " Robert Anderson
2008-06-28 12:38 ` Dmitry Potapov
[not found] ` <20080628123522.GL5737@dpotapov.dyndns.org>
2008-06-28 15:53 ` Robert Anderson
2008-06-28 16:52 ` Dmitry Potapov
2008-06-27 18:15 ` Junio C Hamano
2008-06-27 18:43 ` Robert Anderson
2008-06-28 5:03 ` Jeff King
2008-06-28 7:03 ` Robert Anderson
2008-06-28 8:53 ` Jeff King
2008-06-28 21:53 ` Junio C Hamano
2008-06-28 14:51 ` Johannes Schindelin
2008-07-08 4:58 ` Jeff King
2008-06-27 20:29 ` David Jeske
2008-06-27 20:29 ` David Jeske
2008-06-27 20:47 ` Jakub Narebski
2008-06-27 20:51 ` David Jeske
2008-06-27 20:51 ` David Jeske
[not found] ` <-8386235276716376372@unknownmsgid>
2008-06-27 22:55 ` Robert Anderson
2008-06-27 23:14 ` Junio C Hamano
2008-06-28 0:08 ` Robert Anderson
2008-06-28 2:57 ` Dmitry Potapov
2008-06-28 3:31 ` Robert Anderson
2008-06-28 14:34 ` Stephen Sinclair
2008-06-28 16:00 ` Robert Anderson
2008-06-28 16:30 ` Robert Anderson
2008-06-28 17:12 ` Jakub Narebski
2008-06-28 18:25 ` Robert Anderson
2008-06-28 19:12 ` David Jeske
2008-06-28 19:12 ` David Jeske
2008-06-28 19:13 ` Stephen Sinclair
2008-06-28 0:22 ` David Jeske
2008-06-28 0:22 ` David Jeske
2008-06-28 1:17 Theodore Tso
2008-06-28 1:56 ` Miklos Vajna
-- strict thread matches above, loose matches on Subject: below --
2008-06-28 1:23 Theodore Tso
2008-06-28 9:30 Stephen R. van den Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080627071014.GA12344@atjola.homenet \
--to=b.steinbrink@gmx.de \
--cc=git@vger.kernel.org \
--cc=rwa000@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox