https://github.com/belaytzev/git-scoper
Automatically apply git `user.name` and `user.email` to every repository in a directory β so you never commit with the wrong identity again.
https://github.com/belaytzev/git-scoper
git gitconfig
Last synced: 3 months ago
JSON representation
Automatically apply git `user.name` and `user.email` to every repository in a directory β so you never commit with the wrong identity again.
- Host: GitHub
- URL: https://github.com/belaytzev/git-scoper
- Owner: belaytzev
- License: mit
- Created: 2026-03-01T11:30:06.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-03-22T14:02:23.000Z (4 months ago)
- Last Synced: 2026-03-23T05:17:15.852Z (4 months ago)
- Topics: git, gitconfig
- Language: Go
- Homepage: https://git-scoper.ti1orn.com
- Size: 54.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
git-scoper
> π― Automatically apply git `user.name` and `user.email` to every repository in a directory β so you never commit with the wrong identity again.
[](https://github.com/belaytzev/git-scoper/releases)
[](https://go.dev)
[](https://opensource.org/licenses/MIT)
[](https://github.com/belaytzev/git-scoper/actions)
[](https://github.com/belaytzev/homebrew-tap)
---
## π Table of Contents
- [β¨ Why git-scoper?](#-why-git-scoper)
- [π Quick Start](#-quick-start)
- [π¦ Installation](#-installation)
- [π οΈ Usage](#οΈ-usage)
- [βοΈ Configuration](#οΈ-configuration)
- [π How It Works](#-how-it-works)
- [π Output](#-output)
- [π‘ Example](#-example)
- [π¦ Exit Codes](#-exit-codes)
- [π€ Contributing](#-contributing)
- [π License](#-license)
---
## β¨ Why git-scoper?
Ever committed code with your **personal email** on a **work repo**? Or vice versa? π¬
Managing git identities across dozens of repositories is tedious and error-prone. **git-scoper** fixes that in one command.
- π·οΈ **Scope your identity** β Apply `user.name` and `user.email` to every repo under a directory
- β‘ **Fast & parallel** β Scans directories concurrently with configurable worker count
- π§ **Smart config resolution** β Reads from a local `gitconfig` file or falls back to `~/.gitconfig`
- π **Depth control** β Configure how deep to scan for nested repositories
- π **Safe by default** β Never silently ignores bad config; exits with clear errors
- πΊ **Easy install** β Available via Homebrew or `go install`
---
## π Quick Start
```bash
# Install via Homebrew
brew tap belaytzev/tap && brew install git-scoper
# Create a config file in your work directory
echo -e "name=Jane Doe\nemail=jane@acme.com" > ~/Work/gitconfig
# Apply git identity to all repos under ~/Work
git-scoper ~/Work
```
That's it! π Every git repository under `~/Work` now has the correct identity configured.
---
## π¦ Installation
### πΊ Homebrew (macOS / Linux)
```bash
brew tap belaytzev/tap
brew install git-scoper
```
### π§ From Source
Requires Go 1.21+:
```bash
go install github.com/belaytzev/git-scoper@latest
```
### π Prerequisites
- `git` must be installed and available on `PATH`
---
## π οΈ Usage
```
git-scoper [flags] [base-dir]
```
| Flag | Default | Description |
|------|---------|-------------|
| `--depth` | `2` | π Max directory depth to scan, relative to `base-dir` (depth 1 = immediate children only, depth 2 = one level deeper) |
| `--workers` | `4` | π Parallel workers (must be β₯ 1) |
- If `base-dir` is omitted, the current directory is used.
- If `base-dir` is itself a git repository, config is applied directly to it and no subdirectory scanning occurs.
---
## βοΈ Configuration
git-scoper reads configuration from the following sources (in priority order):
### 1οΈβ£ Local config: `/gitconfig`
A simple key=value format:
```
name=Jane Doe
email=jane@example.com
```
> β οΈ If this file exists but is missing `name=` or `email=`, the tool exits with an error. If the file exists but cannot be accessed (e.g. permission denied) or is a directory, the tool exits with an error rather than falling back to `~/.gitconfig`.
### 2οΈβ£ Global config: `~/.gitconfig`
Standard git INI format β reads the `[user]` section.
---
## π How It Works
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β git-scoper β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. π Read Config β
β ββ /gitconfig ββorββ ~/.gitconfig β
β β
β 2. π Scan Directory β
β ββ Walk up to --depth levels β
β looking for .git/ directories β
β β
β 3. β‘ Apply in Parallel β
β ββ N workers run `git config user.name` β
β and `git config user.email` concurrently β
β β
β 4. π Report Results β
β ββ Updated β
β Failed β β Skipped βοΈ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
---
## π Output
Each scanned path appears as one of:
| Status | Meaning |
|--------|---------|
| β
`Updated: ` | Git config was applied successfully |
| β `Failed: ()` | Git config could not be applied (e.g. not a writable repo) |
| βοΈ `Skipped: ` | Direct child of `base-dir` that contains no git repository within the scan depth |
> π Directories that cannot be read during scanning are silently ignored and do not appear in any output line.
---
## π‘ Example
```
$ git-scoper /Work/Acme
Config: name=Jane Doe, email=jane@acme.com
Scanning: /Work/Acme (depth 2)
------------------------
Updated: ProjectAlpha
Updated: tools/ProjectBeta
Failed: tools/ReadOnly (git config user.name failed: exit status 128)
Skipped: docs
------------------------
Done. 2 updated, 1 failed, 1 skipped.
```
---
## π¦ Exit Codes
| Code | Meaning |
|------|---------|
| `0` β
| All repos updated successfully |
| `1` β | Any failure: invalid flag values (`--depth` or `--workers` less than 1), `base-dir` does not exist or is not a directory, no config found, scan error, or one or more repos reported `Failed:` |
> π‘ **Tip**: Check individual `Failed:` lines for per-repo error details.
---
## π€ Contributing
Contributions are welcome! π
1. π΄ Fork the repository
2. πΏ Create your feature branch (`git checkout -b feature/amazing-feature`)
3. πΎ Commit your changes (`git commit -m 'Add amazing feature'`)
4. π€ Push to the branch (`git push origin feature/amazing-feature`)
5. π Open a Pull Request
Please make sure your code passes CI checks before submitting.
---
## π License
MIT Β© [Alexey Belaytzev](https://github.com/belaytzev)
See [LICENSE](LICENSE) for details.
---
Made with β€οΈ for developers who juggle multiple git identities