git_hook

command
v1.106.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

git_hook

Tailscale's git hooks.

The shared logic lives in the githook/ package and is also imported by tailscale/corp.

Install

From the repo root:

./tool/go run ./misc/add-git-hooks.go

The script auto-updates in the future.

Large file check

The pre-push hook rejects pushes that add or change any blob over 1.5 MB, using the same tree diff logic as the check-file-size CI workflow. To push a large file intentionally, set an environment variable:

TS_SKIP_LARGE_FILE_CHECK=1 git push ...

Adding your own hooks

Create an executable .git/hooks/<hook-name>.local to chain a custom script after a built-in hook. For example, put a custom check in .git/hooks/pre-commit.local and chmod +x it. The local hook runs only if the built-in hook succeeds; failure aborts the git operation.

Version bumps

The launcher rebuilds when the installed binary's version differs from the concatenation of two files:

  • githook/HOOK_VERSION (shared): bump when changing anything under githook/ or git-hook.go. Downstream repos pick it up after bumping their tailscale.com dependency.
  • misc/git_hook/HOOK_VERSION (repo-local, optional): bump to force a rebuild for repo-specific config changes without touching the shared version. This repo does not use one.

Documentation

Overview

The git-hook command is Tailscale's git hook binary, built and installed under .git/hooks/ts-git-hook-bin by the launcher at .git/hooks/ts-git-hook. misc/add-git-hooks.go writes the initial launcher; subsequent HOOK_VERSION bumps trigger self-rebuilds.

Adding your own hooks

To add your own hook alongside one we already hook, create an executable file .git/hooks/<hook-name>.local (e.g. pre-commit.local). It runs after the built-in hook succeeds.

Directories

Path Synopsis
Package githook contains the shared implementation of Tailscale's git hooks.
Package githook contains the shared implementation of Tailscale's git hooks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL