I’m currently on a quest to find a git merge tool I like (or at least get better at handling merge conflicts). I came across this script which is helpful for creating merge conflicts and just thought I’d share:

Given a repo Link to heading

#!/bin/bash
mkdir git-repo
cd git-repo
git init

Which has one commit Link to heading

touch my_code.sh
git add my_code.sh
echo "echo Hello" > my_code.sh
git commit -am 'initial'

And where you have a second commit Link to heading

git checkout -b new_branch
echo "echo \"Hello World\"" > my_code.sh
git commit -am 'first commit on new_branch'

This third commit will make a conflict Link to heading

git checkout main
echo "echo \"Hello World!\"" > my_code.sh
git commit -am 'second commit on master'
git merge new_branch