vkjwlq
Last Updated: November 16, 2017
·
1.31K
· tfnico
C62aa573cdb3cecd291e96b9771844b1

Create a random commit

git

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
Say Thanks
Respond

3 Responses
Add your response

1780
373a135d08c969a8281be834af4e45b8

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

over 1 year ago ·
1789
4e2db9197c36a702219a46a79c024fd0

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

over 1 year ago ·
29430

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

(.*)/\1/p'\'')"'

about 1 month ago ·
Filed Under