All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: Andreas Ericsson <ae@op5.se>
Cc: Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: Question about "git commit -a"
Date: Fri, 05 Oct 2007 14:45:40 +0200	[thread overview]
Message-ID: <vpq641livbf.fsf@bauges.imag.fr> (raw)
In-Reply-To: <47062CD7.70400@op5.se> (Andreas Ericsson's message of "Fri\, 05 Oct 2007 14\:23\:51 +0200")

Andreas Ericsson <ae@op5.se> writes:

> He. It's like comparing a duracell battery to the sun, but yes, that's
> one of the operations where the index is involved. But after doing your
> git-add thing above, you could also have continued hacking on A B C D,
> and git would only have committed the state where you did "git add".
> When you stop to think about this, you'll realize that it's a really
> powerful thing, as it lets you keep on hacking even when you don't
> really know where you'll end up.

That usage is indeed very close to a micro-micro-throwable branch.

Instead of doing:

<hack>
<diff>
<commit>

<hack>
<diff>
<commit>

# Oh, gosh, I didn't want that! | # Yes, _this_ is what I want
$ git reset --hard HEAD^^       | $ git checkout HEAD^^
                                | $ git merge --squash HEAD@{1}
                                  (untested)

You'd do:

<hack>
<diff>
<add>

<hack>
<diff>
<add>

# Oh, gosh, I didn't want that! | # Yes, _this_ is what I want
$ git reset --hard              | $ git commit

The two flows are both similar and different. In the first case, you
can't come back to an arbitrary step within your development, but
since you didn't actually commit, and just ran "add", it's precisely
because you thought this state was not one you wanted to come back to
later. And at the time you commit, you don't have to tell git to
forget about the temporary branch, the succession of "git add" was
just for you, not to keep in history.


Actually, most of the time, I commit only when my index matches the
working tree (i.e. when status shows me only green, with color.status
= auto), so "commit" or "commit -a" don't change the result, but I
validate my own changes with "add", and give the whole thing a
descriptive message with "commit".

-- 
Matthieu

  reply	other threads:[~2007-10-05 12:46 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-04 15:38 Question about "git commit -a" Paolo Ciarrocchi
2007-10-04 15:43 ` Matthieu Moy
2007-10-04 15:48   ` Paolo Ciarrocchi
2007-10-04 15:58 ` Wincent Colaiuta
2007-10-04 20:33   ` Nguyen Thai Ngoc Duy
2007-10-04 21:10     ` Johannes Schindelin
2007-10-04 21:16       ` Nguyen Thai Ngoc Duy
2007-10-04 21:26       ` Shawn O. Pearce
2007-10-05  8:39       ` Paolo Ciarrocchi
2007-10-05  8:52         ` Andreas Ericsson
2007-10-05  9:06           ` Paolo Ciarrocchi
2007-10-05 10:02             ` Andreas Ericsson
2007-10-05 10:11               ` Matthieu Moy
2007-10-05 10:14                 ` Andreas Ericsson
2007-10-05 11:35                   ` Matthieu Moy
2007-10-05 12:17                     ` Andreas Ericsson
2007-10-05 12:19               ` Paolo Ciarrocchi
2007-10-05 12:23                 ` Andreas Ericsson
2007-10-05 12:45                   ` Matthieu Moy [this message]
2007-10-05 15:56           ` Kristian Høgsberg
2007-10-05 16:33             ` Matthieu Moy
2007-10-05 18:16             ` Marko Macek
2007-10-06  7:43               ` Andy Parkins
2007-10-06 16:13                 ` Linus Torvalds
2007-10-07 12:26               ` Wincent Colaiuta
2007-10-05 21:10             ` Dmitry Potapov
2007-10-07  6:12               ` Marko Macek
2007-10-07 14:50                 ` Dmitry Potapov
2007-10-07 16:26                 ` Johannes Schindelin
2007-10-05 10:48         ` Wincent Colaiuta
2007-10-04 21:25 ` Andy Parkins
2007-10-05  6:04   ` Miles Bader
2007-10-04 22:34 ` David Soria
2007-10-04 23:03   ` Alex Riesen
2007-10-04 23:19   ` Johannes Schindelin

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=vpq641livbf.fsf@bauges.imag.fr \
    --to=matthieu.moy@imag.fr \
    --cc=ae@op5.se \
    --cc=git@vger.kernel.org \
    --cc=paolo.ciarrocchi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.