Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [Q] merge squash unexpected conflicts

From: Cory Sharp <hidden>
Date: 2016-06-15 22:46:46

Using git 1.6.3.1, when using "git merge --squash" I get unexpected
conflicts when merging an update to a file that was added after the
original branch point, like this

  * Initialize git repo
  * Add hello to master
  * Create topic branch
  * Add goodbye to master
  * Merge squash master into topic, gets new goodbye
  * Update goodbye in master
  * Again merge squash master into topic, update goodbye

The second merge squash produces a conflict in goodbye.

Am I doing something a little wrong or unexpected?  Is there a way
around this squash conflict behavior?  This doesn't seem to happen
with plain merge without squash.  I've appended a small bash script to
show this behavior - run it from an empty directory.

Thanks,
Cory


#!/bin/sh

try() {
    echo "$@"
    "$@" || exit 1
}

note() {
    echo
    echo "##" "$@" "##"
}

[ -d .git ] && echo .git already exists, aborting. && exit 1

note "Initialize git repo"
try git init

note "Add hello to master"
echo "hello world" > hello.txt
try git add hello.txt
try git commit -m "Added hello"

note "Create topic branch"
try git checkout -b topic

note "Add goodbye to master"
try git checkout master
echo "farewell world" > goodbye.txt
try git add goodbye.txt
try git commit -m "Added goodbye"

note "Merge master into topic, gets new goodbye"
try git checkout topic
try git merge --squash master
try git commit -m "Merged master"

note "Update goodbye in master"
try git checkout master
echo "goodbye world" > goodbye.txt
try git add goodbye.txt
try git commit -m "Updated goodbye"

note "Again merge master into topic, update goodbye"
try git checkout topic
try git merge --squash master
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help