Skip to content

Instantly share code, notes, and snippets.

@smariapena
Last active December 11, 2015 07:38
Show Gist options
  • Save smariapena/cdfa5fb2172bc7f0d820 to your computer and use it in GitHub Desktop.
Save smariapena/cdfa5fb2172bc7f0d820 to your computer and use it in GitHub Desktop.
Git Image Merge Conflict
#!/bin/sh
SCRIPTNAME=$(basename $0)
CURRENT_DIR=$(cd $(dirname $0);pwd)
REPO_PATH="$CURRENT_DIR/image-merge-conflict-test-repo"
if [ -d "$REPO_PATH" ]; then
rm -fr "$REPO_PATH"
fi
mkdir -p "$REPO_PATH" || exit 1
cd "$REPO_PATH" || exit 1
# Init repository
git init .
cat > .gitignore <<EOF
.DS_Store
EOF
git add .
git commit -m "Initial commit"
# Commit base image version
curl http://lorempixel.com/400/200/abstract/base/ -o image.jpg
git add .
git commit -m "Base version of image"
# Create another branch from this revision
git branch develop
# Commit modified image version on master
/bin/rm -f image.jpg
sleep 2 && curl http://lorempixel.com/400/200/abstract/master/ -o image.jpg
git add .
git commit -m "Modified image on master"
# Commit another modified image version on develop
git checkout develop
/bin/rm -f image.jpg
sleep 2 && curl http://lorempixel.com/400/200/abstract/develop/ -o image.jpg
git add .
git commit -m "Modified image on develop"
# Create merge conflict state
git checkout master
git merge develop
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment