# Local Git Excludes

> Use `.git/info/exclude` (per-clone, never pushed) or a global gitignore for personal / machine-local files instead of polluting the team `.gitignore`. Use whenever the user wants to ignore a file privately, asks "will my colleagues see this?", adds personal tooling / IDE configs / symlinks / scratch files to a shared repo, or any time you (the assistant) are about to add a line to a tracked `.git…

- **Type:** Skill
- **Install:** `agentstack add skill-m2laborg-agent-skills-local-git-excludes`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [M2LabOrg](https://agentstack.voostack.com/s/m2laborg)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [M2LabOrg](https://github.com/M2LabOrg)
- **Source:** https://github.com/M2LabOrg/agent-skills/tree/main/local-git-excludes
- **Website:** https://m2laborg.github.io/agent-skills/

## Install

```sh
agentstack add skill-m2laborg-agent-skills-local-git-excludes
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Local Git Excludes — Don't Pollute the Team `.gitignore`

The team's `.gitignore` is **tracked and shared**. Every line you add is committed and pushed for everyone to see. For anything personal — symlinks to your own dotfile/skills repos, scratch notes, IDE configs that nobody else uses, machine-local artifacts — use a **local-only** mechanism instead.

## Three Mechanisms (Pick the Right One)

| Mechanism | Scope | Tracked? | When to use |
|---|---|---|---|
| **Repo `.gitignore`** | This repo, all clones | ✅ Yes | Build outputs, secrets patterns, anything every contributor needs |
| **`.git/info/exclude`** | One clone of one repo | ❌ No | Personal files in a specific shared repo |
| **Global gitignore** (`core.excludesfile`) | Every repo on this machine | ❌ No | Patterns you always want ignored everywhere (e.g. `.DS_Store`, `*.swp`, personal IDE folders) |

## Decision Rule

Before adding a line to a tracked `.gitignore`, ask: **"Would every contributor benefit from this rule?"**

- **Yes** → tracked `.gitignore` is correct.
- **No / only me** → `.git/info/exclude` (this repo) or global gitignore (all repos).
- **Unsure** → default to `.git/info/exclude`. You can always promote it to the tracked file later.

## Mechanism 1 — Per-Clone Exclude (`.git/info/exclude`)

Lives at `/.git/info/exclude`. Same syntax as `.gitignore`. Never pushed (the entire `.git/` directory is local).

```bash
# Add a personal pattern to the current repo only
echo ".claude/skills/my-personal-skill" >> .git/info/exclude

# Verify it's working
git check-ignore -v .claude/skills/my-personal-skill
# .git/info/exclude:N:.claude/skills/my-personal-skill   .claude/skills/my-personal-skill
```

When you re-clone the repo, `.git/info/exclude` resets to the default. **Either re-add the lines** or use the global gitignore for patterns you want everywhere.

## Mechanism 2 — Global Gitignore

One file, applies to every repo on the machine. Set it once.

```bash
# One-time setup
git config --global core.excludesfile ~/.gitignore_global

# Add patterns you always want ignored, anywhere
cat >> ~/.gitignore_global > .git/info/exclude

# 3. Verify
git status                              # should NOT list the file
git check-ignore -v .claude/skills/my-skill  # confirms which rule excluded it
```

## Auditing Before You Commit

Before pushing changes to a tracked `.gitignore`, ask yourself again per line:

```bash
git diff .gitignore
```

For each new line: *"Would I be comfortable explaining this to every reviewer?"* If the answer involves "this is just my personal setup", move it to `.git/info/exclude` instead.

## When You've Already Pushed Personal Stuff to the Team `.gitignore`

Don't panic — gitignore lines are harmless code. To clean up:

```bash
git checkout main && git pull
git checkout -b mdsm/cleanup-gitignore
# remove the personal lines from .gitignore
git commit -am "gitignore: remove personal entries (moved to local exclude)"
# add the same lines to .git/info/exclude on every machine you use
echo "" >> .git/info/exclude
```

Open a small PR, mention briefly that you're moving them to per-clone excludes.

## Bonus — `git update-index --assume-unchanged`

For **tracked** files where you have local-only modifications you don't want to push (e.g. tweaking a config file that lives in the repo):

```bash
git update-index --assume-unchanged path/to/tracked/file
# undo:
git update-index --no-assume-unchanged path/to/tracked/file
```

Use sparingly — it can confuse you later. Prefer rewriting the file's design (template + gitignored override) when this comes up repeatedly.

## Anti-Patterns

- Adding `.idea/`, `.vscode/`, `.DS_Store`, personal symlinks, or `WARP.md`-style assistant configs to the **team** `.gitignore` "for convenience". They belong in the global gitignore.
- Committing personal scratch notes "behind" a `.gitignore` rule for them — the rule reveals you have them.
- Telling colleagues to put a specific line in their local `.gitignore` — give them the global-gitignore recipe instead.
- Forgetting that `.git/info/exclude` is per-clone; treating it as if it follows the repo.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [M2LabOrg](https://github.com/M2LabOrg)
- **Source:** [M2LabOrg/agent-skills](https://github.com/M2LabOrg/agent-skills)
- **License:** MIT
- **Homepage:** https://m2laborg.github.io/agent-skills/

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** yes
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-m2laborg-agent-skills-local-git-excludes
- Seller: https://agentstack.voostack.com/s/m2laborg
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
