From: Jakub Narebski <jnareb@gmail.com>
To: Salvatore Iovene <salvatore.iovene@googlemail.com>
Cc: git@vger.kernel.org
Subject: Re: Problems rebasing branch after renaming files
Date: Fri, 27 Feb 2009 02:55:31 -0800 (PST) [thread overview]
Message-ID: <m3hc2gup2n.fsf@localhost.localdomain> (raw)
In-Reply-To: <c64207c00902270055q57442e2dmd81c197419dda71a@mail.gmail.com>
Salvatore Iovene <salvatore.iovene@googlemail.com> writes:
> Hi list,
> I ran into a problem, and I'm unsure it's a git bug or a misuse of mine.
[...]
> 3) Create branch B and work on it. In this branch, rename a directory
> containing source files with git-mv
> 4) Merge B to master
> 5) Rebase A to master
[...]
> I found that, checking out A, my files in the now renamed directories
> are as the were in B, i.e. not including the changes made in A,
> because I have rebased A to master and git didn't realize that the
> files in old_directory_name are the same as in new_directory_name so
> they should have been merged.
>
> Either this is a git bug or not, can anyone suggest a way to fix this?
> All I've thought so far is to git-format-patch the patches that I had
> in A, use sed to replace the old_directory_name with the new one,
> create a new branch called A2 at master's head, apply the patches
> there and git-branch -D A.
In short: you have rename in mainline, and want to rebase branch from
before rename.
This problem is not bug in git, it is rather limitation of default
patch based rebase. The git-format-patch | git-am pipeline is fast,
but it cannot deal with renames in mainline. You have to use
merge-based rebase, i.e. use
$ git rebase --merge <upstream>
>From git-rebase(1):
-m, --merge
Use merging strategies to rebase. When the recursive (default) merge
strategy is used, this allows rebase to be aware of renames on the
upstream side.
-s <strategy>, --strategy=<strategy>
Use the given merge strategy; can be supplied more than once to
specify them in the order they should be tried. If there is no -s
option, a built-in list of strategies is used instead
(git-merge-recursive when merging a single head, git-merge-octopus
otherwise). This implies --merge.
Or use "git rebase --interactive".
--
Jakub Narebski
Poland
ShadeHawk on #git
prev parent reply other threads:[~2009-02-27 10:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-27 8:55 Problems rebasing branch after renaming files Salvatore Iovene
2009-02-27 10:55 ` Jakub Narebski [this message]
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=m3hc2gup2n.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=salvatore.iovene@googlemail.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).