Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.