I really like the git pull --rebase , but when used in conjunction with a merge conflict, I end up resolving my conflicts twice. I tried using git pull --rebase=preserve , which should make it take merge into account as well.
Try a look at the following example:
# do a new clone "a" $ mkdir origin && cd origin && git init --bare --shared && cd .. $ git clone ./origin a && cd a # Add, commit, push a (master) $ echo "foo" > foo && git add foo && git commit -m "foo" a (master) $ git push origin master # Create branch "b" a (master) $ git branch b # change foo and push a (master) $ echo "// eof " >> foo && git ci -am "eof - master" a (master) $ git push origin master # checkout branch "b", change and push a (master) $ git checkout b a (b) $ echo "// EOF " >> foo && git ci -am "EOF b" && git push origin b # back to master a (b) $ git checkout master # merge a (master) $ git merge b # conflict as expected a (master) $ git diff diff --cc foo index e10b853,1d3cc50..0000000 --- a/foo +++ b/foo @@@ -1,2 -1,2 +1,6 @@@ foo ++<<<<<<< HEAD +// eof ++======= + // EOF ++>>>>>>> b # Now, resolve the conflict a (master|MERGING) $ echo "foo" > foo && echo "// eof" >> foo && git add foo a (master|MERGING) $ git commit # In the mean while somewhere else. ############################################ a (master) $ cd .. && git clone ./origin other && cd other/ other (master) $ echo "bar" > bar && git add bar && git ci -am "bar" && git push # OK # Back to us ################################################################### other (master) $ cd ../a a (master) $ git push # will fail... # I now do a rebase preserve as I want to rebase my merge commit to the top of master a (master) $ git pull --rebase=preserve # This command does not do a very good job... a (master|REBASE-i 1/1) $ git diff diff --cc foo index e10b853,1d3cc50..0000000 --- a/foo +++ b/foo @@@ -1,2 -1,2 +1,6 @@@ foo ++<<<<<<< HEAD +// eof ++======= + // EOF ++>>>>>>> 3cd5d3ac5b870c613233f0a9f1a81df5691ccc7c
If I replaced git pull --rebase=preserve with git pull --no-rebase , then it works as expected (I only need to resolve conflicts once), but then I have to look at all these merge commits in my log.
How can I make a git "rebase" merge and conflict solution to fit on top on a new remote HEAD?
git git-branch
Allan
source share