Last Updated: September 09, 2019
· tfnico

Create a random commit

I often want to just create a commit when testing or showing off some git commands, but lack the creativity or bother to write some recognizable changes or commit messages.

On Mac or Linux, I use this nifty one-liner:

echo "Here's some random content: `random_word`" >> readme.txt; git commit -am "A random commit message: `random_word`"

Now you probably don't have this random_word command on your system yet. Here's what it does (worksforme on both OSX and Ubuntu):

#! /bin/bash
perl -e 'open IN, "</usr/share/dict/words";rand($.) < 1 && ($n=$_) while <IN>;print $n'

Example output:

commit d53935606f130bc99dd8ace491a819f706076057
Author: Thomas Ferris Nicolaisen <...>
Date:   Fri Nov 23 09:18:32 2012 +0100

A random commit message: soundproofing
diff --git a/readme.txt b/readme.txt
+Here's some random content: freight

3 Responses
Add your response

alias bump='echo "" >> .bump && git add .bump && git commit -m "$(curl -qs | sed -nE '\''s/<p>(.*)/\1/p'\'')" .bump' ;)

over 1 year ago ·

@oc cool!
replace echo "" >> .bump with touch .bump

over 1 year ago ·

Improved alias bump='git commit --allow-empty -m "$(curl -qs | sed -nE '\''s/


over 1 year ago ·