gitmap

command module
v0.0.0-...-21ea6c5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 1 Imported by: 0

README

GitMap

CI Go Report Card Go

Scan directories for Git repositories, generate clone instructions, and re-clone them anywhere.

Quick Start

Build
# From the repo root:
.\run.ps1

# Skip git pull:
.\run.ps1 -NoPull

# Build only, no deploy:
.\run.ps1 -NoPull -NoDeploy

# Deploy to custom path:
.\run.ps1 -DeployPath "D:\tools"

# Build and run immediately:
.\run.ps1 -Run
.\run.ps1 -Run -RunPath "D:\projects"
.\run.ps1 -Run -RunArgs "--mode ssh"

The binary and data/ config folder are output to ./bin/. By default, the binary is also copied to the deploy path in powershell.json (default: E:\bin-run).

Manual Build
cd gitmap
go build -o ../bin/gitmap.exe .

Usage

Scan a directory

Every scan always produces all outputs — terminal, CSV, JSON, and a folder structure Markdown file. They are written to a gitmap-output/ folder at the root of the scanned directory.

# Scan current directory (outputs everything to ./gitmap-output/)
gitmap scan
gitmap s                    # shorthand

# Scan a specific folder with SSH URLs
gitmap scan ./projects --mode ssh

# Scan and add repos to GitHub Desktop
gitmap scan ./projects --github-desktop

# Scan and auto-open output folder
gitmap scan ./projects --open

# Custom output directory
gitmap scan ./projects --output-path ./my-exports
Output files

When you run gitmap scan ./projects, the following is created:

projects/
└── gitmap-output/
    ├── gitmap.csv              # All repos in CSV format
    ├── gitmap.json             # All repos in JSON format
    └── folder-structure.md     # Tree view of repo hierarchy

The folder-structure.md shows a visual tree of all discovered repos:

# Folder Structure

Git repositories discovered by gitmap.

├── 📦 **my-app** (`main`) — https://github.com/user/my-app.git
├── libs/
│   ├── 📦 **core-lib** (`develop`) — https://github.com/user/core-lib.git
│   └── 📦 **utils** (`main`) — https://github.com/user/utils.git
└── 📦 **docs** (`main`) — https://github.com/user/docs.git
Output path behavior
Flag Behavior
No flags Creates gitmap-output/ inside the scanned directory
--output-path ./exports Writes to ./exports/
--out-file report.csv Overrides CSV file path only
Clone from a previous scan
# Clone using shorthand (auto-resolves to ./gitmap-output/gitmap.json)
gitmap clone json
gitmap c json               # shorthand alias

# Clone using CSV shorthand
gitmap clone csv

# Clone from JSON with explicit path (preserves original folder structure)
gitmap clone ./gitmap-output/gitmap.json --target-dir ./restored

# Safe-pull existing clones (retries unlink/read-only failures)
gitmap clone ./gitmap-output/gitmap.json --target-dir ./restored --safe-pull

# Clone and add all repos to GitHub Desktop
gitmap clone ./gitmap-output/gitmap.json --target-dir ./restored --github-desktop

The clone command recreates the exact folder hierarchy from the relativePath field in each record. Safe-pull is automatically enabled when existing repos are detected in the target directory — it retries failed pulls, clears read-only attributes, and diagnoses Windows unlink issues. The --safe-pull flag can also be set explicitly. With --github-desktop, successfully cloned repos are automatically registered in GitHub Desktop.


Configuration

data/config.json
{
  "defaultMode": "https",
  "defaultOutput": "terminal",
  "outputDir": "./gitmap-output",
  "excludeDirs": [".cache", "node_modules", "vendor", ".venv"],
  "notes": ""
}

CLI flags override config values.

powershell.json
{
  "deployPath": "E:\\bin-run",
  "buildOutput": "./bin",
  "binaryName": "gitmap.exe",
  "copyData": true
}

CLI Reference

gitmap scan [dir]
Flag Description Default
--config <path> Config file path ./data/config.json
--mode ssh|https Clone URL style https
--output-path <dir> Output directory gitmap-output/ in scan dir
--out-file <path> Exact CSV output file path
--github-desktop Add discovered repos to GitHub Desktop false
--open Open output folder after scan false
gitmap clone <source|json|csv>

Shorthands: gitmap clone json and gitmap clone csv auto-resolve to ./gitmap-output/gitmap.json and ./gitmap-output/gitmap.csv.

Flag Description Default
--target-dir <path> Base clone directory .
--safe-pull Pull existing repos with retries, read-only clear, and diagnosis (auto-enabled) false
--github-desktop Add cloned repos to GitHub Desktop false
--verbose Write detailed debug log to a timestamped file false

Note: --safe-pull is automatically enabled when existing repos are detected in the target directory.

gitmap update [--verbose]
Flag Description Default
--verbose Write detailed debug log to a timestamped file false

CSV Output Columns

repoName, httpsUrl, sshUrl, branch, relativePath, absolutePath, cloneInstruction, notes


Project Structure

gitmap/
├── main.go              # Entry point
├── cmd/                  # CLI commands
│   ├── root.go           # Routing & flags
│   ├── scan.go           # Scan command
│   └── clone.go          # Clone command
├── config/               # Config loading
├── constants/            # All shared string literals
├── scanner/              # Directory walking
├── gitutil/              # Git command wrappers
├── mapper/               # Record building
├── formatter/            # Output (terminal, CSV, JSON, folder structure)
│   ├── terminal.go
│   ├── csv.go
│   ├── json.go
│   └── structure.go      # Folder tree Markdown
├── desktop/              # GitHub Desktop integration
├── cloner/               # Re-clone logic
├── model/                # Data structures
├── data/                 # Default config
│   └── config.json
├── powershell.json       # Build/deploy config
└── go.mod

Command History

Every CLI command is automatically logged to the SQLite database. View the audit trail:

# Show recent history
gitmap history
gitmap hi

# Basic view (just command + time + status)
gitmap history --detail basic

# Detailed view filtered to scan commands
gitmap history --detail detailed --command scan

# Last 5 entries as JSON
gitmap history --json --limit 5

# Clear all history
gitmap history-reset --confirm

Bookmarks

Save and replay frequently-used command+flag combinations:

# Save a bookmark
gitmap bookmark save ssh-scan scan --mode ssh
gitmap bk save quick-status status

# List all bookmarks
gitmap bookmark list
gitmap bk list --json

# Replay a saved bookmark
gitmap bookmark run ssh-scan
gitmap bk run quick-status

# Delete a bookmark
gitmap bookmark delete ssh-scan

Usage Statistics

View aggregated command usage patterns:

# Show all command stats
gitmap stats
gitmap ss

# Stats for a specific command
gitmap stats --command scan

# JSON output
gitmap stats --json

Database Export

Export the full database for backup or sharing:

# Export to default file (gitmap-export.json)
gitmap export
gitmap ex

# Export to custom path
gitmap export backup-2026-03.json

Database Import

Restore a database from a backup file:

# Import from default file
gitmap import --confirm
gitmap im --confirm

# Import from custom path
gitmap import backup-2026-03.json --confirm

Database Profiles

Manage multiple separate database environments:

# Create a new profile
gitmap profile create work
gitmap pf create personal

# List all profiles
gitmap profile list

# Switch active profile
gitmap profile switch work

# Show current profile
gitmap profile show

# Delete a profile
gitmap profile delete personal

Specs

See spec/01-app/ for detailed specifications.

License

Released under the MIT License. © 2026 Md. Alim Ul Karim.

Documentation

Overview

gitmap - Scan directories for Git repos and generate clone instructions.

Directories

Path Synopsis
Package archive owns local archive operations: format identification, compact-extraction (with up to MaxCompactFlattenLayers of duplicate- folder flattening), creation, and listing.
Package archive owns local archive operations: format identification, compact-extraction (with up to MaxCompactFlattenLayers of duplicate- folder flattening), creation, and listing.
Package cloneconcurrency centralizes the worker-count resolver shared by every clone-family command (`clone`, `clone-next`, `clone-now` / `relclone`, `clone-from`).
Package cloneconcurrency centralizes the worker-count resolver shared by every clone-family command (`clone`, `clone-next`, `clone-now` / `relclone`, `clone-from`).
Package clonefrom implements the `gitmap clone-from <file>` workflow: read a JSON or CSV plan from disk, validate every row, render a dry-run preview by default, and on `--execute` shell out to `git clone` for each row with a per-row pass/fail summary.
Package clonefrom implements the `gitmap clone-from <file>` workflow: read a JSON or CSV plan from disk, validate every row, render a dry-run preview by default, and on `--execute` shell out to `git clone` for each row with a per-row pass/fail summary.
Package clonenext — github.go checks and creates GitHub repositories.
Package clonenext — github.go checks and creates GitHub repositories.
Package clonenow implements the `gitmap clone-now <file>` workflow: re-run `git clone` against the JSON / CSV / text artifacts produced by `gitmap scan`, honoring the recorded folder structure and a user-selected SSH/HTTPS mode.
Package clonenow implements the `gitmap clone-now <file>` workflow: re-run `git clone` against the JSON / CSV / text artifacts produced by `gitmap scan`, honoring the recorded folder structure and a user-selected SSH/HTTPS mode.
Package clonepick implements `gitmap clone-pick <repo-url> <paths>`: a partial / sparse-checkout clone of a single git repository, fetching only the requested repo-relative paths into the current working directory (or --dest).
Package clonepick implements `gitmap clone-pick <repo-url> <paths>`: a partial / sparse-checkout clone of a single git repository, fetching only the requested repo-relative paths into the current working directory (or --dest).
Package cloner — read-only audit for clone manifests.
Package cloner — read-only audit for clone manifests.
Commands `gitmap add ignore` and `gitmap add attributes`.
Commands `gitmap add ignore` and `gitmap add attributes`.
Package committransfer implements the commit-replay family: `gitmap commit-left`, `commit-right`, `commit-both`.
Package committransfer implements the commit-replay family: `gitmap commit-left`, `commit-right`, `commit-both`.
Package completion generates shell tab-completion scripts for gitmap.
Package completion generates shell tab-completion scripts for gitmap.
internal/gencommands command
Command gencommands generates allcommands_generated.go by extracting every Cmd* string constant from constants files in the sibling constants/ package that have explicitly opted into completion via marker comments.
Command gencommands generates allcommands_generated.go by extracting every Cmd* string constant from constants files in the sibling constants/ package that have explicitly opted into completion via marker comments.
Package config handles loading and merging configuration.
Package config handles loading and merging configuration.
Package constants defines all shared constant values for gitmap.
Package constants defines all shared constant values for gitmap.
Package dashboard collects Git repository data for the HTML dashboard.
Package dashboard collects Git repository data for the HTML dashboard.
Package desktop integrates with GitHub Desktop application.
Package desktop integrates with GitHub Desktop application.
Package detector — csharpparser.go parses C# project metadata.
Package detector — csharpparser.go parses C# project metadata.
Package diff implements `gitmap diff LEFT RIGHT`: a read-only preview of what `gitmap merge-both / merge-left / merge-right` would change.
Package diff implements `gitmap diff LEFT RIGHT`: a read-only preview of what `gitmap merge-both / merge-left / merge-right` would change.
Package downloaderconfig owns the on-disk + in-DB representation of the gitmap downloader configuration.
Package downloaderconfig owns the on-disk + in-DB representation of the gitmap downloader configuration.
Package errreport collects per-repo failures during long-running gitmap operations (currently `scan` and `clone-next`) and writes a single grouped JSON report at command exit.
Package errreport collects per-repo failures during long-running gitmap operations (currently `scan` and `clone-next`) and writes a single grouped JSON report at command exit.
Package formatter — clonescript.go generates a clone.ps1 PowerShell script.
Package formatter — clonescript.go generates a clone.ps1 PowerShell script.
Package fsutil provides small, dependency-free filesystem predicates that historically existed as duplicated unexported helpers across many gitmap packages (cmd, release, lockfile, localdirs, vscodepm, detector).
Package fsutil provides small, dependency-free filesystem predicates that historically existed as duplicated unexported helpers across many gitmap packages (cmd, release, lockfile, localdirs, vscodepm, detector).
Package gitutil — branch checkout helpers.
Package gitutil — branch checkout helpers.
Package goldenguard centralizes the policy that gates EVERY golden-fixture rewrite path in the gitmap test suite.
Package goldenguard centralizes the policy that gates EVERY golden-fixture rewrite path in the gitmap test suite.
Package localdirs handles migration of legacy repo-local directories.
Package localdirs handles migration of legacy repo-local directories.
Package lockcheck detects processes that hold file locks on a directory.
Package lockcheck detects processes that hold file locks on a directory.
Package lockfile provides a tiny, dependency-free advisory file lock scoped to a single named operation (e.g.
Package lockfile provides a tiny, dependency-free advisory file lock scoped to a single named operation (e.g.
Package mapper converts raw scan data into ScanRecord structs.
Package mapper converts raw scan data into ScanRecord structs.
Package model defines the core data structures for gitmap.
Package model defines the core data structures for gitmap.
Package movemerge implements the file-level move and merge family: `gitmap mv`, `merge-both`, `merge-left`, `merge-right`.
Package movemerge implements the file-level move and merge family: `gitmap mv`, `merge-both`, `merge-left`, `merge-right`.
Package probe — background.go
Package probe — background.go
Package release — assets.go orchestrates cross-compilation for Go projects.
Package release — assets.go orchestrates cross-compilation for Go projects.
Package render — pretty-mode policy.
Package render — pretty-mode policy.
Live progress emitter for the parallel scanner.
Live progress emitter for the parallel scanner.
Package scripts embeds the canonical install / uninstall shell scripts so that subcommands like `gitmap self-install` can run them offline.
Package scripts embeds the canonical install / uninstall shell scripts so that subcommands like `gitmap self-install` can run them offline.
Package setup configures Git global settings from a JSON config file.
Package setup configures Git global settings from a JSON config file.
Package stablejson encodes JSON arrays of objects with a field order that is GUARANTEED stable across Go versions, encoding/json rewrites, and any future encoding/json/v2 transition.
Package stablejson encodes JSON arrays of objects with a field order that is GUARANTEED stable across Go versions, encoding/json rewrites, and any future encoding/json/v2 transition.
Package startup manages user-scoped autostart entries created by gitmap on the host OS:
Package startup manages user-scoped autostart entries created by gitmap on the host OS:
Package store manages the SQLite database for gitmap.
Package store manages the SQLite database for gitmap.
Package templates — Diff primitive.
Package templates — Diff primitive.
Package verbose provides a shared debug logger that writes to a timestamped log file when --verbose is enabled.
Package verbose provides a shared debug logger that writes to a timestamped log file when --verbose is enabled.
Package vscodepm syncs gitmap repos into the alefragnani.project-manager VS Code extension's projects.json file.
Package vscodepm syncs gitmap repos into the alefragnani.project-manager VS Code extension's projects.json file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL