Skip to content

Instantly share code, notes, and snippets.

@nh2

nh2/generate-test-git.sh

Last active Aug 29, 2015
Embed
What would you like to do?
Generates a git repository with dual history and some branches on top (for fixing a Jenkins performance bug)
#!/bin/bash
# Creates a git repository called "testgit-generated"
# with two separate histories branching from the initial
# commit, each being 500 commits long.
# On top of each, we create 200 branches with one extra
# commit per branch.
# Should take around 30 seconds.
set -e
# Create repo
mkdir testgit-generated
cd testgit-generated
echo start > myfile
git init
git add myfile
git commit -m "Initial commit"
git branch init
# Create history 1 (500 commits)
git checkout -b history1 init
for i in {1..500}; do
echo "commit $i"
date +%s%N >> myfile
git commit -am "`date +%s%N`"
done
# Create 200 branches on top of history 1
for i in {1..200}; do
echo "branch $i"
git reset --hard
git checkout -f -b `date +%s%N` history1
date +%s%N >> myfile
git commit -am "`date +%s%N`"
done
# Create history 2 (500 commits)
git checkout -b history2 init
for i in {1..500}; do
echo "commit $i"
date +%s%N >> myfile
git commit -am "`date +%s%N`"
done
# Create 200 branches on top of history 2
for i in {1..200}; do
echo "branch $i"
git reset --hard
git checkout -f -b `date +%s%N` history2
date +%s%N >> myfile
git commit -am "`date +%s%N`"
done
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.