Git dibs
Claim a git commit id so that other developers know not to use it. Reciprocate by not using theirs.
Call dibs on a commit id
No longer do you need to send an email to everyone in your company or post a heads-up on LinkedIn that you're reserving a sha-1 hash for future use.
Now it's as easy as git dibs.
dev@crudco:~/crud-app$
Never again accidentally steal another developer's dibs
Install our post-commit hook in your repo to roll back any attempt to violate another developer's trust and goodwill. Tell your teammates they're lucky the reset is --soft, and you won't be so generous next time.
dev@crudco:~/crud-app$
Check for dibs
If you don't want a post-commit hook calling you a cotton-headed ninnymuggins for trying to steal an innocent developer's commit id, you can preemptively check against the registry with the following git alias. You don't want to commit a war crime, do you?
dev@crudco:~/crud-app$
Post-Commit Hook Installation
- Install
pre-commit,colorama, andgit-dibs-sdkwithpython -m pip install pre-commit colorama git-dibs-sdk. - Put
git-dibs-checker.pyin the root of your repository. - Create a
.pre-commit-config.yamlfile like the one below. The sample usesuv; if you are not using it, change the entry topython ./git-dibs-checker.py. - Run
pre-commit install --hook-type post-commitso Git actually installs thepost-commithook.
git-dibs-checker.py
#!/usr/bin/env python3
import subprocess
import sys
from colorama import just_fix_windows_console, Fore
just_fix_windows_console()
from git_dibs_sdk import GitDibsClient
def recent_commit() -> str | None:
result = subprocess.run(
["git", "log", "-1", "--pretty=format:%H", "HEAD"],
check=True,
capture_output=True,
text=True,
)
return result.stdout.strip() or None
def soft_reset(commit_id: str) -> None:
subprocess.run(
["git", "reset", "--soft", f"{commit_id}~1"],
check=True,
capture_output=True,
text=True,
)
print(f"{Fore.YELLOW}Soft reset {commit_id}{Fore.RESET}", file=sys.stderr)
client = GitDibsClient("https://gitdibs.com")
commit_id = recent_commit()
if commit_id is None:
sys.exit(0)
dibs = client.lookup_commit(commit_id)
if dibs is not None:
print(
f"{Fore.RED}Sorry, {dibs.reserved_by} already called dibs on commit {commit_id}. Please pad a random file with whitespace and try again.{Fore.RESET}",
file=sys.stderr,
)
soft_reset(commit_id)
.pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: git-dibs-checker
name: git dibs check
language: unsupported
entry: uv run python ./git-dibs-checker.py
stages: [post-commit]
always_run: true
pass_filenames: false
files: ^$
repos:
- repo: local
hooks:
- id: git-dibs-checker
name: git dibs check
language: unsupported
entry: uv run python ./git-dibs-checker.py
stages: [post-commit]
always_run: true
pass_filenames: false
files: ^$
Git Alias Installation
If you prefer pure ceremony over forms, add git dibs and git dibs-check
aliases backed by small Python scripts.
- Install
coloramaandgit-dibs-sdkwithpython -m pip install colorama git-dibs-sdk. - Copy
git-dibs.pyandgit-dibs-check.pyinto your repository root. - Open your repository
.git/configor your global~/.gitconfig. - Add the alias block below.
- Run
git dibs <40-char-commit-id> <AlphanumericName>, for examplegit dibs deadbeefdeadbeefdeadbeefdeadbeefdeadbeef SamFromLondon. - Run
git dibs-check <40-char-commit-id>to see whether a commit is already taken and by whom.
The sample scripts route everything through the shared Python SDK so the output stays readable and the
HTTP details stay out of your shell history. git-dibs.py uses colorama for
green and red terminal output.
git-dibs.py
#!/usr/bin/env python3
import sys
from colorama import Fore, just_fix_windows_console
just_fix_windows_console()
from git_dibs_sdk import (
DibsAlreadyCalledError,
GitDibsClient,
GitDibsError,
)
client = GitDibsClient("https://gitdibs.com")
commit_id = sys.argv[1].strip().lower()
reserved_by = sys.argv[2].strip()
try:
dibs = client.reserve_commit(commit_id, reserved_by)
except DibsAlreadyCalledError as error:
owner = error.reserved_by or "someone else"
print(f"{Fore.RED}Sorry, {error.commit_hash} is already reserved by {owner}.{Fore.RESET}", file=sys.stderr)
raise SystemExit(1)
except GitDibsError as error:
print(f"{Fore.RED}{error}{Fore.RESET}", file=sys.stderr)
raise SystemExit(1)
print(f"{Fore.GREEN}{dibs.hash} was successfully reserved{Fore.RESET}")
git-dibs-check.py
#!/usr/bin/env python3
import sys
from git_dibs_sdk import GitDibsClient, GitDibsError
client = GitDibsClient("https://gitdibs.com")
commit_id = sys.argv[1].strip().lower()
try:
dibs = client.lookup_commit(commit_id)
except GitDibsError as error:
print(error, file=sys.stderr)
raise SystemExit(1)
if dibs is None:
print(f"{commit_id} is available!")
else:
print(f"{dibs.hash} is reserved by {dibs.reserved_by}")
.gitconfig
[alias]
dibs = "!f() { python ./git-dibs.py \"$@\"; }; f"
dibs-check = "!f() { python ./git-dibs-check.py \"$@\"; }; f"
[alias]
dibs = "!f() { python ./git-dibs.py \"$@\"; }; f"
dibs-check = "!f() { python ./git-dibs-check.py \"$@\"; }; f"
Call dibs on a commit
If you're "not a command line person", that's okay. Just copy-paste your desired commit id in the form below and hit "Dibs!"
Search for reserved commit ids
Check to see of a hash is reserved, or just look up your personal favorite.
Search Results
Matching reserved commits for your current query.
| Upvotes | Commit | Name | Reserved |
|---|
10 Most Recent Reserved Commits
Get yours before they run out. Only 1.4615016e+48 left!
| Upvotes | Commit | Name | Reserved |
|---|
10 Most Popular Commits
Don't forget to vote on your favorite. Your vote matters!
| Upvotes | Commit | Name | Reserved |
|---|
Frequently asked question
Why?