Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Instant Git Merge Practice
#!/bin/bash
rm my-code.txt > /dev/null 2>&1 &
rm -rf .git > /dev/null 2>&1 &
touch my-code.txt
git init
git add my-code.txt
echo ' --------------------------- ' > my-code.txt
echo ' fruit, computer or colours? ' >> my-code.txt
echo ' --------------------------- ' >> my-code.txt
echo ' ' >> my-code.txt
echo ' apple ' >> my-code.txt
echo ' orange ' >> my-code.txt
echo ' pear ' >> my-code.txt
echo ' ' >> my-code.txt
echo ' --------------------------- ' >> my-code.txt
echo ' right, wrong, left or kept? ' >> my-code.txt
echo ' --------------------------- ' >> my-code.txt
echo ' ' >> my-code.txt
echo ' right ' >> my-code.txt
echo ' left ' >> my-code.txt
echo ' ' >> my-code.txt
echo ' --------------------------- ' >> my-code.txt
git commit -am 'initial commit'
git checkout -b feature-branch
echo ' --------------------------- ' > my-code.txt
echo ' fruit, computer or colours? ' >> my-code.txt
echo ' --------------------------- ' >> my-code.txt
echo ' ' >> my-code.txt
echo ' apple ' >> my-code.txt
echo ' dell ' >> my-code.txt
echo ' hp ' >> my-code.txt
echo ' ' >> my-code.txt
echo ' --------------------------- ' >> my-code.txt
echo ' right, wrong, left or kept? ' >> my-code.txt
echo ' --------------------------- ' >> my-code.txt
echo ' ' >> my-code.txt
echo ' right ' >> my-code.txt
echo ' wrong ' >> my-code.txt
echo ' ' >> my-code.txt
echo ' --------------------------- ' >> my-code.txt
git commit -am 'wrong not left; dell not orange'
git checkout master
echo ' --------------------------- ' > my-code.txt
echo ' fruit, computer or colours? ' >> my-code.txt
echo ' --------------------------- ' >> my-code.txt
echo ' ' >> my-code.txt
echo ' blue ' >> my-code.txt
echo ' orange ' >> my-code.txt
echo ' green ' >> my-code.txt
echo ' ' >> my-code.txt
echo ' --------------------------- ' >> my-code.txt
echo ' right, wrong, left or kept? ' >> my-code.txt
echo ' --------------------------- ' >> my-code.txt
echo ' ' >> my-code.txt
echo ' kept ' >> my-code.txt
echo ' left ' >> my-code.txt
echo ' ' >> my-code.txt
echo ' --------------------------- ' >> my-code.txt
git commit -am 'second commit on master'
git merge feature-branch
git mergetool my-code.txt
@snoblenet

This comment has been minimized.

Copy link
Owner Author

commented Oct 5, 2017

To use:

  • Download the file to a directory that is not a Git repo
  • Make the file executable (chmod +x conflicted.sh)
  • Run the file (./conflicted.sh)
  • Merge!
  • Run the file again (./conflicted.sh) for more practice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.