Skip to content

Instantly share code, notes, and snippets.

@BowiFromStackOverflow
Created August 26, 2021 08:24
Show Gist options
  • Save BowiFromStackOverflow/5575fd41cf8944b72557083f359914ae to your computer and use it in GitHub Desktop.
Save BowiFromStackOverflow/5575fd41cf8944b72557083f359914ae to your computer and use it in GitHub Desktop.
Small git-imerge conflict example
git init
echo "for file in *.txt; do cat \$file | sed \"s/ / [\$file] /\" ; done | sort" > partyLog.sh
git add partyLog.sh
git commit -m "Add automatic party log parser"
echo "00:00:00 Hey, I am Adam. I am all alone at this party." >> adam.txt
echo "00:04:54 Hey, it is so boring here! Why isn't there anybody?" >> adam.txt
git add adam.txt
git commit -m "Start host log"
git checkout -b markerForBisectLater
git checkout master
echo "00:07:01 I am now joining the party." >> berta.txt
echo "00:08:10 Drinking some wine." >> berta.txt
echo "00:12:25 Eating some cake." >> berta.txt
git add berta.txt
git commit -m "Berta log lines"
echo "00:08:05 Hey, cool, other guests arriving!" >> adam.txt
git add adam.txt
git commit -m "Update host log"
git checkout -b caesar
git checkout master
echo "00:09:57 Drinking some wine." >> adam.txt
echo "00:14:37 Eating some cake." >> adam.txt
git add adam.txt
git commit -m "Update happy host log"
git checkout caesar
echo "00:07:39 I am now joining the celebritas." >> caesar.txt
echo "00:08:07 Drinking some vinum." >> caesar.txt
git add caesar.txt
git commit -m "The emperor has joined the party"
git checkout master
echo "00:15:39 Drinking some wine." >> adam.txt
echo "00:17:40 Drinking some coffee." >> berta.txt
git add adam.txt berta.txt
git commit -m "Some more drinking"
echo "00:20:31 Dancing to the music!" >> adam.txt
git add adam.txt
git commit -m "Dancing"
git checkout caesar
echo "00:10:00 Drinking the rest of the vinum." >> caesar.txt
git add caesar.txt
git commit -m "The emperor has consumed all the wine"
echo "00:12:59 No vinum left, I am leaving towards another celebritas now." >> caesar.txt
git add caesar.txt
git commit -m "The emperor has left the party"
git checkout master
git-imerge start --name=joinCaesarToTheParty --first-parent --goal=merge caesar
# When we now run
# source partyLog.sh
# , we get this:
# 00:00:00 [adam.txt] Hey, I am Adam. I am all alone at this party.
# 00:04:54 [adam.txt] Hey, it is so boring here! Why isn't there anybody?
# 00:07:01 [berta.txt] I am now joining the party.
# 00:07:39 [caesar.txt] I am now joining the celebritas.
# 00:08:05 [adam.txt] Hey, cool, other guests arriving!
# 00:08:07 [caesar.txt] Drinking some vinum.
# 00:08:10 [berta.txt] Drinking some wine.
# 00:09:57 [adam.txt] Drinking some wine.
# 00:10:00 [caesar.txt] Drinking the rest of the vinum.
# 00:12:25 [berta.txt] Eating some cake.
# 00:12:59 [caesar.txt] No vinum left, I am leaving towards another celebritas now.
# 00:14:37 [adam.txt] Eating some cake.
# 00:15:39 [adam.txt] Drinking some wine.
# 00:17:40 [berta.txt] Drinking some coffee.
# 00:20:31 [adam.txt] Dancing to the music!
# See at 00:15:39, Adam is drinking wine despite Caesar having drunk all of it!
# With bisecting, we find the bad (merge) commit.
# git bisect start
# git bisect bad
# git checkout markerForBisectLater
# git bisect good
# ...
@BowiFromStackOverflow
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment