Skip to content

Instantly share code, notes, and snippets.

@snoblenet
Created October 5, 2017 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snoblenet/6567d94aff189255c6eb300753c5e796 to your computer and use it in GitHub Desktop.
Save snoblenet/6567d94aff189255c6eb300753c5e796 to your computer and use it in GitHub Desktop.
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
Copy link
Author

snoblenet 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