public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* Question about merge & cherry pick
@ 2024-11-06 20:24 Julien Maurel
  2024-11-07  6:37 ` Johannes Sixt
  0 siblings, 1 reply; 5+ messages in thread
From: Julien Maurel @ 2024-11-06 20:24 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-11-07 17:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-06 20:24 Question about merge & cherry pick Julien Maurel
2024-11-07  6:37 ` Johannes Sixt
2024-11-07 10:32   ` Julien Maurel
2024-11-07 12:02     ` brian m. carlson
2024-11-07 17:18     ` Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox