Skip to content

Instantly share code, notes, and snippets.

@tobywf
Created January 25, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tobywf/0743a9241171ff5cc9406d7ba696c8f8 to your computer and use it in GitHub Desktop.
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
#!/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