Initialize Trunk in a git repo

Whether you aim to use Trunk Check, Trunk Merge, Trunk Actions, or all of the above, the first step is to initialize Trunk in your git repo:

trunk init

Note: for an extra layer of security you can optionally run trunk init --lock instead of trunk init which adds sha256s of the trunk cli to the trunk config file. This is then used by the Trunk Launcher when it downloads the trunk binary.

init scans the files in your repo and generates a .trunk/trunk.yaml configuration file tailored to your repo (it may also generate linter-specific config files, such as .shellcheckrc). The scan will identify all the particular languages and technologies you use and automatically configure the correct set of linters / formatters to run.

If you only want to use Trunk Merge, you can safely ignore the linter setup, or even strip enabled linters from .trunk/trunk.yaml. You will additionally need to login to use Trunk Merge via trunk login.

Don't want to commit .trunk/trunk.yaml into your repo yet?

You can use Trunk without committing anything into your repo by adding a local gitignore for the .trunk folder.

echo "/.trunk/" >> .git/info/exclude

When you're ready to commit the .trunk/trunk.yaml file into your repo for your teammates to use, just clear your .git/info/exclude file and commit the files in .trunk.

Did this page help you?