/git-vanity-sha

vanity hex prefixes for your commit SHAs

Primary LanguageRubyOtherNOASSERTION

git vanity-sha

This is a Very Good Program inspired by this tweet.

He wasn't joking.

So I thought maybe I'd just write a program to do it.

git vanity-sha will try its darndest to tweak the commiter timestamp of your last commit to produce a commit SHA using the hexadecimal prefix you supply.

$ git commit -am "refactor warp core"
[master 909939a] refactor warp core
 1 file changed, 12 insertions(+), 8 deletions(-)

$ git vanity-sha cafe
Searching for new SHA...

SHA found: cafe7f7fe2054aa79dd6f5e1f994242b70cd7572
Change committer timestamp to 2018-04-27 00:31:18 -0700? This will amend your commit.
(y/n): y

-----------------------------------------------
commit cafe7f7fe2054aa79dd6f5e1f994242b70cd7572
Author: Matt Baker <matt@example.com>

refactor warp core

Now you can amend a commit to have a quirky prefix whenever you want except for when git-vanity-sha doesn't find one.

Installation

Grab the git-vanity-sha script and stick it in your path somewhere. Make sure you chmod +x it, and hash -r.

Now you can say git vanity-sha beef in your repo.

Frequently Asked Questions

How does it work?

git vanity-sha will attempt to find a commit SHA starting with the hex prefix you specify by applying a delta to the committer timestamp of your last commit. It starts off making small changes to the timestamp (a few seconds) and gets bigger as it searches (up to several days).

If it finds a timestamp that will cause your commit's SHA to have the target prefix, it will give you the option to amend that commit or abort the process.

Is this a good idea?

Absolutely not.

Will this mess something up?

Probably.

Will you help me if something goes wrong?

Oh god no.

It didn't find a SHA with the prefix I wanted :(

If you're really determined, then change TIMESTAMP_DELTA_MAX to a huge number and go for a walk and maybe you'll get lucky.

It doesn't work, the hash doesn't have the proper prefix!

Do you have commit signing enabled? You need to disable it, otherwise it won't work due to git limitations.