# Git protection

> Nothing on a Mac can stop an agent skipping your git checks for good. Excellent notices the skip, and can move the protection to GitHub or GitLab, where the agent can't reach it.

An agent can skip your repository's git checks with `--no-verify`, and nothing on your Mac can stop that every time.
So Excellent does two things: it notices the skip and names the commit, and it can move the protection to your git
server, where the agent can't reach it.

Open the Git page from the Protection page. It lists your repositories without going online.

## Notice skipped checks

**Watch Commits for Skipped Checks…** points that repository's git hooks at a small wrapper in its `.git/excellent`
folder. The wrapper runs your own hooks, then marks the commit as checked. A commit made without them shows up as the
finding **Commits were made without your repo's checks**.

**Stop Watching…** puts your hooks setting back.

## Protect main on the server

**Check GitHub and GitLab** reads each repository's branch protection, using the sign-in you already have: the `gh` or
`glab` tool, or a `GH_TOKEN`, `GITHUB_TOKEN` or `GITLAB_TOKEN` you set. Your token goes from your Mac straight to
GitHub or GitLab.

**Protect Main…** changes that protection, after you confirm:

- on GitHub, main can't be force pushed or deleted, and a check is required once you commit the workflow it writes;
- on GitLab, main can't be force pushed.

For a GitHub repository whose checks are in a tracked file, it writes `.github/workflows/excellent-checks.yml` into the
repository on your Mac, uncommitted. Commit and push it, and GitHub re-runs those checks.

**Undo…** on the Git page takes the protection off and removes that workflow file. Commit the deletion.

## A remote on this Mac

If your project pushes to a folder on this Mac, **Install Server Hook…** adds a hook there that runs your checks again
on each push. **Remove Hook…** takes it out.

Source: https://www.excellent.so/docs/git
