git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Q] merge squash unexpected conflicts

From
CSCory Sharp <cory.sharp@gmail.com>
Date
May 14, 2009, 02:42 UTC
Message-ID
<bb9d69200905131942t7a43a29fh9638d2548e9f12dc@mail.gmail.com>
In-Reply-To
<bb9d69200905131706m61b0dda1xc347ca2e719ec142@mail.gmail.com>

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

Next: Junio C Hamano
Message 1 of 11 in “Re: [Q] merge squash unexpected conflicts”
  1. Cory SharpMay 14, 2009
  2. Junio C HamanoMay 14, 2009
  3. Cory SharpMay 14, 2009
  4. Junio C HamanoMay 14, 2009
  5. Cory SharpMay 14, 2009
  6. Junio C HamanoMay 14, 2009
  7. Cory SharpMay 14, 2009
  8. Michael RadziejMay 14, 2009
  9. Cory SharpMay 14, 2009
  10. Michael J GruberMay 14, 2009
  11. Cory SharpMay 14, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.