Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

"git merge -s ours" vs "git merge -X ours"

By: a guest on Oct 11th, 2012  |  syntax: Bash  |  size: 0.69 KB  |  views: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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