Skip to content

Automatic Updates

Note: This guide primarily describes features beneficial for Consumers – those using libraries managed by a Creator. The setup of the hook itself might be done by a Creator or an advanced Consumer.

KiLM provides a helper command kilm add-hook to easily create a basic post-merge Git hook that runs kilm sync.

Navigate to the root of your Git repository containing your KiCad libraries and run:

Terminal window
kilm add-hook

This creates a .git/hooks/post-merge script that automatically executes kilm sync every time you successfully run git pull or git merge in that repository.

If you prefer manual setup or want to customize the hook script further, you can follow these steps:

  1. Create Hook Directory (if needed): Make sure the hooks directory exists in your repository:

    Terminal window
    mkdir -p .git/hooks
  2. Create Hook Script: Create a file named .git/hooks/post-merge.

  3. Add Script Content: Add the commands you want to run. For basic KiLM integration, use:

    #!/bin/sh
    # BEGIN KiLM-managed section
    # KiCad Library Manager auto-update hook
    # Added manually
    echo "Running KiCad Library Manager sync..."
    kilm sync
    # Uncomment to set up libraries automatically (use with caution)
    # kilm setup
    echo "KiCad libraries sync complete."
    # END KiLM-managed section
  4. Make Executable: Set the execute permission:

    Terminal window
    chmod +x .git/hooks/post-merge

When you run git pull or git merge:

  1. Git executes the post-merge hook automatically
  2. The hook runs kilm sync to check for library updates
  3. If new versions are available, they are pulled from remote repositories
  4. Your local KiCad libraries stay synchronized with the latest versions

You can modify the hook to automatically run kilm setup after updates by uncommenting the kilm setup line. This is useful for automatically updating KiCad’s configuration files, but use with caution as it modifies your KiCad setup.

Add any other commands you want to run after library updates, such as:

  • Notifications or logging
  • Additional validation steps
  • Integration with other tools
  • Ensure the hook file has execute permissions (chmod +x .git/hooks/post-merge)
  • Check that you’re running git pull or git merge (not git fetch)
  • Verify the hook is in the correct repository’s .git/hooks directory

If your repository uses git config core.hooksPath, KiLM will automatically detect and use that location. You can check your current hooks path with:

Terminal window
git config core.hooksPath

For repositories using Git worktrees, KiLM correctly identifies the main repository location and installs hooks in the appropriate hooks directory.