Created
January 25, 2018 15:18
-
-
Save tobywf/0743a9241171ff5cc9406d7ba696c8f8 to your computer and use it in GitHub Desktop.
A script to generate a test repo with two feature branches for the git merge vs git rebase tutorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eux | |
create_commit() { | |
git checkout "$1" | |
echo "$2" > src.txt | |
git commit -am "$2" | |
git log --graph --pretty=format:'%s %C(yellow)%d%Creset' | |
sleep 2 # make the commits distinctive in time | |
} | |
mkdir test && cd test/ | |
git init | |
# inital commit | |
echo "A" > src.txt | |
git add -- src.txt | |
git commit -am "A" | |
git log --graph --pretty=format:'%s %C(yellow)%d%Creset' | |
sleep 2 | |
# create two branches off master | |
git checkout -b feature1 | |
git checkout master | |
git checkout -b feature2 | |
# two programmers working at the same time | |
create_commit feature1 "B" | |
create_commit feature2 "D" | |
create_commit feature1 "C" | |
create_commit feature2 "E" | |
git checkout master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment