#!/bin/sh mkdir gittest cd gittest git init git checkout master echo "Line one" > bar git add bar git commit -m "Original commit" git checkout -b fork1 echo "Line one and something" > bar echo "Line two" > bam git add bar bam git commit -m "Fork1 commit." git checkout master git checkout -b fork2 echo "Line one and other stuff" > bar echo "Line three" > baz git add bar baz git commit -m "Fork2 commit." git checkout fork1 if [ "$1" = "ours" ]; then # `ls gittest` => bam bar # `cat gittest/bar` => Line one and something git merge -s ours fork2 else # `ls gittest` => bam bar baz # `cat gittest/bar` => Line one and something git merge -X ours fork2 fi