# rebase --continue confusion

12 messages from 2010-05-30 to 2010-06-07. Participants: Dale Rowley, Tim Visher, skillzero@gmail.com, Junio C Hamano, Ramkumar Ramachandra, Jan Krüger, Eli Barzilay, Jeff King.
Thread: https://gitlist.dev/t/23942

## Dale Rowley, 2010-05-30 00:59

Subject: rebase --continue confusion
Message-ID: <4C01B855.7080409@gmail.com>
URL: https://gitlist.dev/e/4C01B855.7080409%40gmail.com

```
I ran into a conflict while running 'git rebase branch1 branch2'. So I edited
the file and resolved the conflicts, and then ran 'git add <file>; git rebase
--continue'. This printed out a message 'No changes - did you forget to use git
add?'. I thought 'No, I'm pretty sure I ran git add' and I assumed I had run
into a bug in git because I didn't see how this conflict was different than any
others I had successfully resolved. The next time this problem came up, the
light finally came on and I realized that I should just run 'git rebase --skip'
because when I resolved the conflicts, I had basically undone all changes that
the patch would introduce.

OK, so there isn't a bug in git, but since then I've seen co-workers stumped by
this same problem. So maybe it would help to clarify the message? Maybe
something like "The index is in the same state as it was before the patch was
applied - refusing to make an empty commit. Did you forget to use 'git add'? Or
maybe you should use 'git rebase --skip'?"


Dale

```

## Tim Visher, 2010-05-30 12:44

Subject: Re: rebase --continue confusion
Message-ID: <AANLkTika8osPqvlcZKqVTMN5IwLxBZioBCD1NgLHj0EQ@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTika8osPqvlcZKqVTMN5IwLxBZioBCD1NgLHj0EQ%40mail.gmail.com
In-Reply-To: <4C01B855.7080409@gmail.com>

```
On Sat, May 29, 2010 at 8:59 PM, Dale Rowley <ddrowley@gmail.com> wrote:
> I ran into a conflict while running 'git rebase branch1 branch2'. So I edited
> the file and resolved the conflicts, and then ran 'git add <file>; git rebase
> --continue'. This printed out a message 'No changes - did you forget to use git
> add?'. I thought 'No, I'm pretty sure I ran git add' and I assumed I had run
> into a bug in git because I didn't see how this conflict was different than any
> others I had successfully resolved. The next time this problem came up, the
> light finally came on and I realized that I should just run 'git rebase --skip'
> because when I resolved the conflicts, I had basically undone all changes that
> the patch would introduce.
>
> OK, so there isn't a bug in git, but since then I've seen co-workers stumped by
> this same problem. So maybe it would help to clarify the message? Maybe
> something like "The index is in the same state as it was before the patch was
> applied - refusing to make an empty commit. Did you forget to use 'git add'? Or
> maybe you should use 'git rebase --skip'?"

2 things.

1. I agree that the message could be more informative, especially
given the context.  If the the patch looks exactly like the last patch
applied now that you've edited it during a rebase, it would _almost_
be safe to assume that you meant to skip and just didn't know you were
going to before hand.

2. `git status` should show you that you had nothing to commit, which
would completely explain why `git rebase --continue` threw out the
message it did.  I'm in the habit of running `git st` continually and
it often helps me catch this sort of thing where I thought I'd added
something to the index or forgot that I'd changed some file between
the last time I'd updated the index or something along those lines.
This is just sort of a recommendation on a way to modify your work
flow that may help you and your coworkers in the future.  YMMV.

-- 

In Christ,

Timmy V.

http://burningones.com/
http://five.sentenc.es/ - Spend less time on e-mail

```

## skillzero@gmail.com, 2010-05-31 00:14

Subject: Re: rebase --continue confusion
Message-ID: <AANLkTinjyaIndGmu1yiJI_Nwbyq3pB5ef0w9BgDmDpeh@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTinjyaIndGmu1yiJI_Nwbyq3pB5ef0w9BgDmDpeh%40mail.gmail.com
In-Reply-To: <4C01B855.7080409@gmail.com>

```
On Sat, May 29, 2010 at 5:59 PM, Dale Rowley <ddrowley@gmail.com> wrote:
> I ran into a conflict while running 'git rebase branch1 branch2'. So I edited
> the file and resolved the conflicts, and then ran 'git add <file>; git rebase
> --continue'. This printed out a message 'No changes - did you forget to use git
> add?'. I thought 'No, I'm pretty sure I ran git add' and I assumed I had run
> into a bug in git because I didn't see how this conflict was different than any
> others I had successfully resolved. The next time this problem came up, the
> light finally came on and I realized that I should just run 'git rebase --skip'
> because when I resolved the conflicts, I had basically undone all changes that
> the patch would introduce.
>
> OK, so there isn't a bug in git, but since then I've seen co-workers stumped by
> this same problem. So maybe it would help to clarify the message? Maybe
> something like "The index is in the same state as it was before the patch was
> applied - refusing to make an empty commit. Did you forget to use 'git add'? Or
> maybe you should use 'git rebase --skip'?"

I agree. I actually wasn't as smart as you when I saw that message in
the past. I didn't know what the problem was and I didn't know about
git rebase --skip (or I probably ignored it when I tried git rebase -h
since skipping didn't sound like what I wanted at the time, but thanks
for pointing it out if run into this in the future). I think I'd like
git to just skip automatically in this case.

```

## Junio C Hamano, 2010-05-31 19:31

Subject: Re: [PATCH] git-am: suggest what to do with superfluous patches
Message-ID: <7vwrujzx3t.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vwrujzx3t.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20100530101926.3bac34c8jk@jk.gs@perceptron>

```
Jan Krüger <jk@jk.gs> writes:

> Particularly in the context of rebase, conflicts frequently occur
> because the change in the patch to be applied was made obsolete by new
> upstream commits. In this case, solving the conflict effectively means
> skipping the patch. However, it's not always readily apparent that the
> patch needs to be skipped, and when people solve the conflict and try
> git rebase --continue, they get confronted with a message of
>
>   No changes - did you forget to use 'git add'?
>
> That's not very helpful if you did actually stage your changes and they
> happen to turn the patch into a no-op. This extends the message to point
> out what's going on.
>
> Signed-off-by: Jan Krüger <jk@jk.gs>
> ---

I think this is a change in a good direction; we _might_ want to allow
this squelched with "advice.*" configuration, but my gut feeling is that
it wouldn't probably matter much, as it is rather rare to trigger this.

> diff --git a/git-am.sh b/git-am.sh
> index 87ffae2..43ea52c 100755
> --- a/git-am.sh
> +++ b/git-am.sh
> @@ -726,6 +726,8 @@ do
>  		resolved=
>  		git diff-index --quiet --cached HEAD -- && {
>  			echo "No changes - did you forget to use 'git add'?"
> +			echo "If there is nothing left to stage, chances are that something else"
> +			echo "already introduced the same changes; you might want to skip this patch."

The exact wording I'd let people to fight out, but I think this is
probably better than Ramkumar's one that says "if you dropped".  The user
may not know that he is doing an equivalent of dropping as a side effect
of the new base that had accepted the same change, and your message nudges
the reader to realize that.

```

## Ramkumar Ramachandra, 2010-05-31 20:17

Subject: Re: [PATCH] git-am: suggest what to do with superfluous patches
Message-ID: <AANLkTinRafLwhzxUuijdBzfzxLtTb_ua3aM1IxVCCgfa@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTinRafLwhzxUuijdBzfzxLtTb_ua3aM1IxVCCgfa%40mail.gmail.com
In-Reply-To: <7vwrujzx3t.fsf@alter.siamese.dyndns.org>

```
Hi Junio,

Junio C Hamano <gitster@pobox.com> wrote:
> Jan Krüger <jk@jk.gs> writes:
>> diff --git a/git-am.sh b/git-am.sh
>> index 87ffae2..43ea52c 100755
>> --- a/git-am.sh
>> +++ b/git-am.sh
>> @@ -726,6 +726,8 @@ do
>>               resolved=
>>               git diff-index --quiet --cached HEAD -- && {
>>                       echo "No changes - did you forget to use 'git add'?"
>> +                     echo "If there is nothing left to stage, chances are that something else"
>> +                     echo "already introduced the same changes; you might want to skip this patch."
>
> The exact wording I'd let people to fight out, but I think this is
> probably better than Ramkumar's one that says "if you dropped".  The user
> may not know that he is doing an equivalent of dropping as a side effect
> of the new base that had accepted the same change, and your message nudges
> the reader to realize that.

I didn't see this patch on the list- did Jan send it to the list?
Yeah, the wording here is nicer, except you might also want to include
an explicit note on using "$cmdline --skip".

-- Ram

```

## Jan Krüger, 2010-05-31 22:51

Subject: Re: [PATCH] git-am: suggest what to do with superfluous patches
Message-ID: <20100601005139.6d0f87c4@jk.gs>
URL: https://gitlist.dev/e/20100601005139.6d0f87c4%40jk.gs
In-Reply-To: <AANLkTinRafLwhzxUuijdBzfzxLtTb_ua3aM1IxVCCgfa@mail.gmail.com>

```
Ramkumar Ramachandra <artagnon@gmail.com> wrote:

> I didn't see this patch on the list- did Jan send it to the list?
> Yeah, the wording here is nicer, except you might also want to include
> an explicit note on using "$cmdline --skip".

Yes, I did, but apparently something I changed in my mail setup a while
ago caused the list server to silently drop mails sent to the list. I
think I've fixed it now. Sorry for the confusion.

-Jan

```

## Eli Barzilay, 2010-06-06 13:10

Subject: Re: rebase --continue confusion
Message-ID: <m3bpbo1f3f.fsf@winooski.ccs.neu.edu>
URL: https://gitlist.dev/e/m3bpbo1f3f.fsf%40winooski.ccs.neu.edu
In-Reply-To: <4C01B855.7080409@gmail.com>

```
Dale Rowley <ddrowley@gmail.com> writes:
>
> OK, so there isn't a bug in git, but since then I've seen co-workers
> stumped by this same problem. So maybe it would help to clarify the
> message? Maybe something like "The index is in the same state as it
> was before the patch was applied - refusing to make an empty
> commit. Did you forget to use 'git add'? Or maybe you should use
> 'git rebase --skip'?"

There are a number of these things that I asked about recently.
Here's another similarly one:

  $ git add foo
  $ git status -s
  M  foo
  $ git commit --amend foo
  # On branch master
  # No changes
  $ git status -s
  M  foo

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

```

## Jeff King, 2010-06-06 22:18

Subject: Re: rebase --continue confusion
Message-ID: <20100606221853.GG6993@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20100606221853.GG6993%40coredump.intra.peff.net
In-Reply-To: <m3bpbo1f3f.fsf@winooski.ccs.neu.edu>

```
On Sun, Jun 06, 2010 at 09:10:44AM -0400, Eli Barzilay wrote:

> There are a number of these things that I asked about recently.
> Here's another similarly one:
> 
>   $ git add foo
>   $ git status -s
>   M  foo
>   $ git commit --amend foo
>   # On branch master
>   # No changes
>   $ git status -s
>   M  foo

I'm confused. Is there some context for when you are issuing these
commands? Because the "git commit --amend foo" should actually commit
foo, and does for me.

-Peff

```

## Eli Barzilay, 2010-06-06 22:32

Subject: Re: rebase --continue confusion
Message-ID: <19468.8730.59682.76355@winooski.ccs.neu.edu>
URL: https://gitlist.dev/e/19468.8730.59682.76355%40winooski.ccs.neu.edu
In-Reply-To: <20100606221853.GG6993@coredump.intra.peff.net>

```
On Jun  6, Jeff King wrote:
> On Sun, Jun 06, 2010 at 09:10:44AM -0400, Eli Barzilay wrote:
> 
> > There are a number of these things that I asked about recently.
> > Here's another similarly one:
> > 
> >   $ git add foo
> >   $ git status -s
> >   M  foo
> >   $ git commit --amend foo
> >   # On branch master
> >   # No changes
> >   $ git status -s
> >   M  foo
> 
> I'm confused. Is there some context for when you are issuing these
> commands?  Because the "git commit --amend foo" should actually
> commit foo, and does for me.

Heh, in that case it was more effective than I thought...  My point in
the previous posts was also about missing information (in that case,
make `git add' tell you when adding it canceled previously added
changes, and also make `git status' tell you if you're in the middle
of a merge or rebase and in a clean state).

In any case, here's the prelude to the above:

  $ mkdir t; cd t; git init
  $ echo foo > foo; git add foo; git commit -m foo
  $ echo bar > foo; git commit -o foo -m bar
  $ echo foo > foo

(And as cooked as it seems, I posted it because I actually ran into it
this morning.)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

```

## Jeff King, 2010-06-06 22:46

Subject: Re: rebase --continue confusion
Message-ID: <20100606224601.GB11424@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20100606224601.GB11424%40coredump.intra.peff.net
In-Reply-To: <19468.8730.59682.76355@winooski.ccs.neu.edu>

```
On Sun, Jun 06, 2010 at 06:32:58PM -0400, Eli Barzilay wrote:

> > >   $ git add foo
> > >   $ git status -s
> > >   M  foo
> > >   $ git commit --amend foo
> > >   # On branch master
> > >   # No changes
> > >   $ git status -s
> > >   M  foo
> > 
> > I'm confused. Is there some context for when you are issuing these
> > commands?  Because the "git commit --amend foo" should actually
> > commit foo, and does for me.
> 
> Heh, in that case it was more effective than I thought...  My point in
> the previous posts was also about missing information (in that case,
> make `git add' tell you when adding it canceled previously added
> changes, and also make `git status' tell you if you're in the middle
> of a merge or rebase and in a clean state).
> 
> In any case, here's the prelude to the above:
> 
>   $ mkdir t; cd t; git init
>   $ echo foo > foo; git add foo; git commit -m foo
>   $ echo bar > foo; git commit -o foo -m bar
>   $ echo foo > foo

Ah, I see. Your problem has nothing to do with explicit pathnames (which
I thought was the interesting bit from your snippet), but rather that
you are amending it to the same as HEAD^.

Probably it would be helpful in the case of an amend to indicate what
has happened (you have no changes, but it is not immediately obvious
that you have no changes against HEAD^, not HEAD). We could even
suggest "git reset HEAD^", which is probably what you want (the only
other thing you could want is to create a commit with no changes, which
we generally try to avoid).

-Peff

```

## Eli Barzilay, 2010-06-06 23:42

Subject: Re: rebase --continue confusion
Message-ID: <19468.12912.509183.102990@winooski.ccs.neu.edu>
URL: https://gitlist.dev/e/19468.12912.509183.102990%40winooski.ccs.neu.edu
In-Reply-To: <20100606224601.GB11424@coredump.intra.peff.net>

```
On Jun  6, Jeff King wrote:
> On Sun, Jun 06, 2010 at 06:32:58PM -0400, Eli Barzilay wrote:
> 
> > > >   $ git add foo
> > > >   $ git status -s
> > > >   M  foo
> > > >   $ git commit --amend foo
> > > >   # On branch master
> > > >   # No changes
> > > >   $ git status -s
> > > >   M  foo
> > > 
> > > I'm confused. Is there some context for when you are issuing these
> > > commands?  Because the "git commit --amend foo" should actually
> > > commit foo, and does for me.
> > 
> > Heh, in that case it was more effective than I thought...  My point in
> > the previous posts was also about missing information (in that case,
> > make `git add' tell you when adding it canceled previously added
> > changes, and also make `git status' tell you if you're in the middle
> > of a merge or rebase and in a clean state).
> > 
> > In any case, here's the prelude to the above:
> > 
> >   $ mkdir t; cd t; git init
> >   $ echo foo > foo; git add foo; git commit -m foo
> >   $ echo bar > foo; git commit -o foo -m bar
> >   $ echo foo > foo
> 
> Ah, I see. Your problem has nothing to do with explicit pathnames (which
> I thought was the interesting bit from your snippet), but rather that
> you are amending it to the same as HEAD^.

Yes.


> Probably it would be helpful in the case of an amend to indicate
> what has happened (you have no changes, but it is not immediately
> obvious that you have no changes against HEAD^, not HEAD). We could
> even suggest "git reset HEAD^", which is probably what you want (the
> only other thing you could want is to create a commit with no
> changes, which we generally try to avoid).

Yes, that sounds reasonable.  (When I realized what happened I
wondered why it didn't do the reset itself, but that would obviously
be a bad idea.)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

```

## Jeff King, 2010-06-07 00:41

Subject: Re: rebase --continue confusion
Message-ID: <20100607004146.GA25106@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20100607004146.GA25106%40coredump.intra.peff.net
In-Reply-To: <19468.12912.509183.102990@winooski.ccs.neu.edu>

```
On Sun, Jun 06, 2010 at 07:42:40PM -0400, Eli Barzilay wrote:

> > Probably it would be helpful in the case of an amend to indicate
> > what has happened (you have no changes, but it is not immediately
> > obvious that you have no changes against HEAD^, not HEAD). We could
> > even suggest "git reset HEAD^", which is probably what you want (the
> > only other thing you could want is to create a commit with no
> > changes, which we generally try to avoid).
> 
> Yes, that sounds reasonable.  (When I realized what happened I
> wondered why it didn't do the reset itself, but that would obviously
> be a bad idea.)

I'm not convinced this comes up often enough to really be worth worrying
about, but the patch is quite trivial, so why not?

-- >8 --
Subject: [PATCH] commit: give advice on empty amend

We generally disallow empty commits with "git commit". The
output produced by the wt_status functions is generally
sufficient to explain what happened.

With --amend commits, however, things are a little more
confusing. We would create an empty commit not if you
actually have staged changes _now_, but if your staged
changes match HEAD^. In this case, it is not immediately
obvious why "git commit" claims no changes, but "git status"
does not. Furthermore, we should point the user in the
direction of git reset, which would eliminate the empty
commit entirely.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/commit.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 4b2a468..10b09b9 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -48,6 +48,11 @@ static const char implicit_ident_advice[] =
 "\n"
 "    git commit --amend --author='Your Name <you@example.com>'\n";
 
+static const char empty_amend_advice[] =
+"You asked to amend the most recent commit, but doing so would make\n"
+"it empty. You can repeat your command with --allow-empty, or you can\n"
+"remove the commit entirely with \"git reset HEAD^\".\n";
+
 static unsigned char head_sha1[20];
 
 static char *use_message_buffer;
@@ -706,6 +711,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	if (!commitable && !in_merge && !allow_empty &&
 	    !(amend && is_a_merge(head_sha1))) {
 		run_status(stdout, index_file, prefix, 0, s);
+		if (amend)
+			fputs(empty_amend_advice, stderr);
 		return 0;
 	}
 
-- 
1.7.1.458.g792cd.dirty

```
