From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Duy Nguyen <pclouds@gmail.com>, Git Mailing List <git@vger.kernel.org>
Subject: Re: splitting a commit that adds new files
Date: Sun, 2 Feb 2014 18:11:10 -0500 [thread overview]
Message-ID: <20140202231110.GC16196@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqzjm9fkk4.fsf@gitster.dls.corp.google.com>
On Sun, Feb 02, 2014 at 10:15:07AM -0800, Junio C Hamano wrote:
> Duy Nguyen <pclouds@gmail.com> writes:
>
> > I usually start splitting a commit with "reset @^" then "add -p" back.
> > The problem is "reset @^" does not keep track of new files added in
> > HEAD, so I often end up forgetting to add new files back (with "add
> > -p"). I'm thinking of making "reset" to do "add -N" automatically for
> > me so I won't miss changes in "add -p". But maybe people already know
> > how to deal with this case without adding more code?
>
> Is "reset -p" what you are looking for? I do not use that myself,
> though.
I don't think so. He is at a commit that needs split, so the first thing
to do is to shift the HEAD back. "reset -p" is only about changing the
index[1]. I suppose you could start with a soft reset, and then "reset
-p" away the changes. But then you are going backwards ("this does not
belong in the commit, remove it" rather than "this does belong in the
commit, add it").
I don't typically have a problem with this because I keep my directory
free of untracked files (they are either marked by .gitignore, or
something that I am planning to commit). So just running "git status"
gives me a neat list of what needs to be added (and typically "git add
-N ." is a good starting point upon which to build a "git add -p"
session).
-Peff
[1] I _do_ use "reset -p" when splitting commits, but I do not think it
is useful here. I use it for "oops, I staged this change, but it
actually belongs in the next commit. Undo my staging, but leave the
changes in the working tree for the next one".
next prev parent reply other threads:[~2014-02-02 23:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-01 10:48 splitting a commit that adds new files Duy Nguyen
2014-02-02 18:15 ` Junio C Hamano
2014-02-02 23:11 ` Jeff King [this message]
2014-02-03 18:11 ` Junio C Hamano
2014-02-04 0:54 ` Duy Nguyen
2014-02-04 2:20 ` [PATCH 1/2] t7101, t7014: rename test files to indicate what that file is for Nguyễn Thái Ngọc Duy
2014-02-04 2:20 ` [PATCH 2/2] reset: support "--mixed --intent-to-add" mode Nguyễn Thái Ngọc Duy
2014-02-04 19:09 ` Junio C Hamano
2014-02-04 22:25 ` Junio C Hamano
2014-02-05 0:27 ` Duy Nguyen
2014-02-05 17:16 ` Junio C Hamano
2014-02-05 18:25 ` Junio C Hamano
2014-02-05 23:48 ` Duy Nguyen
2014-02-06 0:08 ` Junio C Hamano
2014-02-06 0:43 ` Junio C Hamano
2014-02-04 16:05 ` [PATCH 1/2] t7101, t7014: rename test files to indicate what that file is for Jonathan Nieder
2014-02-06 1:58 ` Duy Nguyen
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=20140202231110.GC16196@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@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;
as well as URLs for NNTP newsgroup(s).