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

Question about merge & cherry pick

From
JMJulien Maurel <julien@maurel.me>
Date
Nov 6, 2024, 20:24 UTC
Message-ID
<711a0faa-6d82-48b6-819d-9ddbeda03f6a@maurel.me>
Hi,
I detect a potential issue with usage of merge and cherry pick.
I do a short script to reproduce my use case.
 From my point of view, after these operations, content on branch master 
and dev should be same with "zZz" on second line and "eDe" on last one.
But it's not the case on second line...
I test the same thing with first commit on master, cherrypick on dev, 
second update on dev, merge dev on master, result is same.
And I test to cherry pick second commit on master after final merge, 
cherry pick is ok and "fix" master content.
Can you help me to understand if it's normal or not ?

The script : mkdir repo cd repo

# Create a file and init 2 branches with same content git init echo -e "aAa\nzZz\nqQq\neEe" > file git add . git commit -a -m "init" git checkout -b dev

# Update on dev sed -i "s#Z#Y#" file git commit -a -m "update"

# Cherrypick on master git checkout master git cherry-pick -x dev

# Second update on dev git checkout dev sed -i "s#Y#Z#" file sed -i "s#E#D#" file git commit -a -m "update that change second line as before first update and do another change"

# Merge on master git checkout master git merge dev --no-ff -m "Merge"

# Display result echo echo echo MASTER cat file git checkout dev > /dev/null 2>&1 echo echo DEV cat file

Thanks
Next: Johannes Sixt
Message 1 of 5 in “Question about merge & cherry pick”
  1. Julien MaurelNov 6, 2024
  2. Johannes SixtNov 7, 2024
  3. Julien MaurelNov 7, 2024
  4. brian m. carlsonNov 7, 2024
  5. Johannes SixtNov 7, 2024

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.