1. #!/bin/sh
  2.  
  3. mkdir gittest
  4. cd gittest
  5. git init
  6.  
  7. git checkout master
  8. echo "Line one" > bar
  9. git add bar
  10. git commit -m "Original commit"
  11.  
  12. git checkout -b fork1
  13. echo "Line one and something" > bar
  14. echo "Line two" > bam
  15. git add bar bam
  16. git commit -m "Fork1 commit."
  17.  
  18. git checkout master
  19. git checkout -b fork2
  20. echo "Line one and other stuff" > bar
  21. echo "Line three" > baz
  22. git add bar baz
  23. git commit -m "Fork2 commit."
  24.  
  25. git checkout fork1
  26. if [ "$1" = "ours" ]; then
  27.   # `ls gittest` => bam bar
  28.   # `cat gittest/bar` => Line one and something
  29.   git merge -s ours fork2
  30. else
  31.   # `ls gittest` => bam bar baz
  32.   # `cat gittest/bar` => Line one and something
  33.   git merge -X ours fork2
  34. fi