Is this what they call an 'Evil Merge' (git style) where the final content was
not in either of the original commits.
In such cases it's hard to attribute which source commit contained the data
that is in the merge.
It's as if an additional change was added, over and above choosing between
which of the source commit changes should 'win' when line conflict.
- Original Message -
From: Blind
To: git-users@googlegroups.com
Sent: Friday, February 01, 2013 5:07 PM
Subject: [git-users] Re: Rebasing problems
I tryed your thing, and yes in both cases we end up with a file without 7.5
line in it ...
this is not good from my point of view...
git rebase --preserve-merges still keeps the "S",
but he keeps only the info of the changes introduced from the both parents,
he forgot about your "manual change".
I guess a further investigation at the point of:
git merge --no-commit dev1
sed --in-place -e '/^8$/i7.5' file
git commit -a -m 'Commit S'
wil make sence.
I am still not sure if it is a "git commit" problem in case of middle of
merge,
or maybe somebody forgot to diff-tree correctly the things...
I am surely very interested how this will turn out.
31 януари 2013, четвъртък, 19:47:21 UTC+2, Dale Worley написа:
I'm investigating how rebase works, and I'm finding that it doesn't
work well if the rebased branch contains merges. Am I using rebase
incorrectly?
In particular, if there are merge commits on the old branch that
contain changes that are not contained in either of the commits that
are merged, rebase doesn't carry them properly into the new branch.
(This sort of merge is not unusual; there may be adjustments needed to
combine two sets of changes for reasons other than a purely textual
collision between the changes.)
As far as I can tell, rebase without --preserve-merges entirely
ignores merge commits on the old branch. Rebase with
--perserve-merges seems to recreate the new merges de novo rather than
by examining the old merge to determine what it changes. Neither of
these actions is optimal (IMHO).
As a test case, I've written the following shell script. It's written
for Linux, but the comments should be clear enough to allow manually
executing the git commands on other systems. The places where I think
Git is behaving poorly are marked with "***". Following the script is
the output of my execution of the script.
The beginning of the script creates this commit structure:
A---B---C---D master
\
\ Q
\ / \
P S---T dev
\ /
R
The goal is to rebase dev (calling it branch 'rebase') to the head of
master. But getting the changes that are in S that are not in Q or R
carried into the new branch seems to be impossible.
--
set -ve
# Create a temporary directory and go into it.
DIR=temp.$$
mkdir $DIR
cd $DIR
# Create a Git repository.
git init
# Create a file containing the lines 1 to 10.
seq 1 10 >file
git add file
git commit -m 'Commit A'
# Start the dev branch at commit A.
git branch dev HEAD
# Add lines 1.5, 2.5, and 3.5 in a series of commits on master.
# This sed command adds a line 1.5 before the line 2.
sed --in-place -e '/^2$/i1.5' file
git commit -a -m 'Commit B'
sed --in-place -e '/^3$/i2.5' file
git commit -a -m 'Commit C'
sed --in-place -e '/^4$/i3.5' file
git commit -a -m 'Commit D'
# Show the commit structure of master.
git log --graph --oneline master
git log --graph -p master
# Go to the dev branch and create commits with a non-trivial merge.
git checkout dev
sed --in-place -e '/^5$/i4.5' file
git commit -a -m 'Commit P'
git branch dev1 HEAD
sed --in-place -e '/^6$/i5.5' file
git commit -a -m 'Commit Q'
git checkout dev1
sed --in-place -e '/^7$/i6.5' file
git commit -a -m 'Commit R'
git checkout dev
# Merge commits Q and R, but add the additional line 7.5 (to simulate
# fixes that were needed to resolve the merge).
git merge --no-commit dev1
sed --in-place -e '/^8$/i7.5' file
git commit -a -m 'Commit S'
sed --in-place -e '/^9$/i8.5' file
git commit -a -m 'Commit T'
# Show the commit structure of dev.
git log --graph --oneline dev
# *** Note that the diffs do not show the line 7.5 added in commit S.
git log --graph -p dev
# Rebase the dev branch to the tip of master.
git checkout dev
git branch -f rebase dev
git checkout rebase
git rebase master
# Show the commit structure.
git log --graph