git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tim Guirgies <lt.infiltrator@gmail.com>
To: Howard Miller <howard@e-learndesign.co.uk>
Cc: git@vger.kernel.org
Subject: Re: Can't get git rebase --onto to work
Date: Thu, 2 Jun 2011 20:38:35 +1000	[thread overview]
Message-ID: <20110602103833.GA4709@Imperial-SSD-Overlord> (raw)
In-Reply-To: <BANLkTikF7p_XsU6YJ81bq10S3nL6tBsApg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2437 bytes --]

On Thu, Jun 02, 2011 at 11:17:41AM +0100, Howard Miller wrote:
> Trying to explain this as concisely as possible.
> 
> I started with the following branches (names changed to protect the guilty)...
> 
> * clientA
> * clientB
> 
> both have a common ancestry....
> 
> I then checked out clientB created a new branch clientB_patch and did
> a load of work and commits.
> 
> However, I actually wanted all those commits to apply to clientA
> branch instead so....
> 
> git checkout clientA
> git checkout -b clientA_patch     (to ensure I didn't wreck original branch)
> git rebase --onto clientA_patch clientB clientB_patch
> 
> It says "rewinding" head and then applies the commits I would have expected.
> 
> However, I have now been switched to the 'clientB_patch' branch and it
> says that it differs from its tracked remote branch by hundreds of
> commits.
> 
> clientA_patch is unchanged. It seems to have mangled clientB_patch and
> done nothing to clientA_patch. Where did I go wrong?

"--onto clientA_patch"

Please read that out loud.  It's meaning in git is the same as in
English.  What you did was rebase clientB_patch _onto_ clientA_patch.
For more information, see "git help rebase".

What you should have done instead:

git checkout -b clientA_patch clientB_patch
git rebase -i clientA

What that does is create and then checkout a branch called clientA_patch
at the same commit as clientB_patch, then rebase your currently checked
out branch (clientA_patch) on top of clientA; the "-i" option allows you
double check what's being rebased, as otherwise it would take a whole
lot clientB history with it.  Simply delete the lines with the commits
you don't want.


To fix what you currently have, though, you must do the following.  Take
heed, however, as I making assumptions that the situation is unchanged
from what you described above.

git checkout clientB_patch
git reset --hard origin/clientB_patch

I'm assuming your remote is called origin, and also that whatever you
pushed last is the latest.  If not, you'll have to look at "git reflog"
to see which commit to reset the branch to.

Now do:

git checkout clientA_patch
git reset --hard clientB_patch
git rebase -i clientA

That should give you what you want.

Good luck.


Tim

-- 
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org   - against proprietary attachments

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2011-06-02 10:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-02 10:17 Can't get git rebase --onto to work Howard Miller
2011-06-02 10:32 ` Carlos Martín Nieto
2011-06-02 10:38   ` Howard Miller
2011-06-02 10:38 ` Tim Guirgies [this message]
2011-06-02 10:43   ` Howard Miller
2011-06-02 10:52     ` Tim Guirgies
2011-06-02 10:58       ` Howard Miller
2011-06-02 11:18         ` David
2011-06-02 11:18         ` Tim Guirgies
2011-06-02 11:28           ` Howard Miller

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=20110602103833.GA4709@Imperial-SSD-Overlord \
    --to=lt.infiltrator@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=howard@e-learndesign.co.uk \
    /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).