git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Pierre-Luc Loyer <Pierre-Luc.Loyer@bhvr.com>
Cc: "git\@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Git Rebase Issue
Date: Tue, 22 Dec 2015 11:25:52 -0800	[thread overview]
Message-ID: <xmqqwps6cmkf.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <39E7EE9D306F544FAD3A0D16B7B7CAAD2C1E819D@mtlsvrmxwv02.A2M.com> (Pierre-Luc Loyer's message of "Tue, 22 Dec 2015 17:53:42 +0000")

Pierre-Luc Loyer <Pierre-Luc.Loyer@bhvr.com> writes:

> From the documentation it says that <branch> (which is HEAD) will be checked out before doing anything and that upon completion, <branch> will be the current branch. However, this doesn't seem to happen. In fact, it seems more like the following is happening during the rebase:
> 1) detach HEAD
> 2) rebase
> 3) reattach to <branch>

You do not have to say "HEAD" for "<branch>", if you are rebasing
the current branch.  Either leave it unsaid, or name the branch.

Passing "HEAD" (or any of its variants that names the exact commit
at the tip of the current branch, without using the name of the
current branch, e.g. "master^0") as the "branch to rebase" is an
advanced technique to use when you want to avoid messing with the
branch itself.  It is deliberate that the HEAD is left detached.

You'd (once you learn Git sufficently and got comfortable with
working on a detached HEAD, that is) often find yourself doing
things like this:

1. rebase temporarily on detached HEAD

    $ git rebase -i HEAD~2 HEAD ;# amend the tip two

2. double check the result and convince yourself that it is better
   than the original

    $ git diff master HEAD

    $ git log master.. >updated
    $ git log -2 master >original
    $ diff -u original updated

3-a. once satisfied, update the branch

    $ git checkout -B master

3-b. or abandon if the result is undesirable.

    $ git checkout master

  reply	other threads:[~2015-12-22 19:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 17:53 Git Rebase Issue Pierre-Luc Loyer
2015-12-22 19:25 ` Junio C Hamano [this message]
2015-12-22 21:02 ` Christian Couder
  -- strict thread matches above, loose matches on Subject: below --
2023-03-13 12:35 git rebase issue Andy Shevchenko
2023-03-13 12:58 ` Andy Shevchenko
2023-03-20 12:10   ` Andy Shevchenko
2023-03-20 14:41     ` Felipe Contreras
2023-03-20 17:01     ` Jeff King
2023-03-20 17:20       ` Andy Shevchenko
2023-03-23 20:37         ` Felipe Contreras
2023-03-24  7:52           ` Andy Shevchenko

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqwps6cmkf.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Pierre-Luc.Loyer@bhvr.com \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).