Core library for managing temporary git repository clones.
$ dotnet add package QuinntyneBrown.Git.CoreA .NET global tool and core library for cloning git repositories into managed temporary folders.
| Package | Description |
|---|---|
| QuinntyneBrown.Git.Core | Core library with git and temp folder services. Consumable by any .NET 8+ project. |
| QuinntyneBrown.Git.Cli | .NET global tool that exposes the core library as a CLI. |
# From the repo
eng\scripts\install-cli.bat
# Or manually
dotnet pack src\QuinntyneBrown.Git.Cli -c Release
dotnet tool install --global --add-source src\QuinntyneBrown.Git.Cli\bin\Release QuinntyneBrown.Git.Cli
dotnet add package QuinntyneBrown.Git.Core
Register services via dependency injection:
using QuinntyneBrown.Git.Core;
services.AddGitCore();
Then inject IGitService or ITempFolderService where needed.
dotnet tool uninstall --global QuinntyneBrown.Git.Cli
Clone a git repository to a temporary folder. Outputs the path to the temporary folder.
git-cli clone <url> [--branch <branch>] [--commit <commit>] [--tag <tag>]
git-cli clone --tag <tag>
| Option | Alias | Default | Description |
|---|---|---|---|
--branch | -b | The branch to clone or verify | |
--commit | The commit to clone or verify | ||
--tag | -t | A label to save or look up an existing clone |
If the repository has already been cloned and matches the requested branch/commit, the existing path is returned. Otherwise the tool re-clones.
Tags let you bookmark a clone so you can retrieve it later without the full URL:
# Clone and tag it
git-cli clone https://github.com/user/repo --tag my-repo
# Later, retrieve by tag alone
git-cli clone --tag my-repo
If a tag does not exist, the tool prints a message with usage guidance:
Tag 'my-repo' does not exist. Provide a URL to clone the repository:
git-cli clone <url> --tag my-repo
Show the diff between a branch inferred from the URL and the default branch.
git-cli diff <url> [--default-branch <branch>] [--output <path>] [--include-files <path>]
| Option | Alias | Default | Description |
|---|---|---|---|
--default-branch | -d | main | The base branch to diff against |
--output | -o | (stdout) | File path to write the diff to |
--include-files | Write an additional file with the default branch contents optimized for LLM consumption |
The branch is inferred from the URL (e.g. https://github.com/user/repo/tree/feature-branch). The repo is cloned to a temporary folder if not already cached. When --include-files is provided, the full contents of the default branch are written to the specified path using the same token-efficient XML format as the files command.
Aggregate all repository text files into a single file optimized for LLM consumption.
git-cli files <url> [--branch <branch>] [--output <path>]
| Option | Alias | Default | Description |
|---|---|---|---|
--branch | -b | (default branch) | The branch to clone or verify |
--output | -o | <repo-name>.txt in CWD | File path to write the output to |
Files are emitted in a token-efficient XML format:
<file path="src/Program.cs">
file contents
</file>
Binary files, build output (bin/, obj/), and common non-text directories (.git, node_modules, dist, etc.) are automatically excluded.
Delete the temporary folder for a specific git repository.
git-cli clean <url>
Delete all temporary folders created by the tool.
git-cli purge
Temporary folders are created under %TEMP%/git-cli/ using a hash of the repository URL. Each cloned folder contains a .git-cli-url marker file for traceability. The tool drives the git command line directly, so git must be installed and on your PATH.
src/
QuinntyneBrown.Git.Core/
Services/
IGitService.cs # Git operations contract
GitService.cs # Drives git CLI via Process
ITempFolderService.cs # Temp folder management contract
TempFolderService.cs # Temp folder lifecycle management
GitUrlParser.cs # Extracts repo URL and branch from full URLs
RepoContentAggregator.cs # Aggregates repo files for LLM consumption
ServiceCollectionExtensions.cs # DI registration (AddGitCore)
QuinntyneBrown.Git.Cli/
Commands/
CloneCommand.cs # git-cli clone
CleanCommand.cs # git-cli clean
PurgeCommand.cs # git-cli purge
DiffCommand.cs # git-cli diff
FilesCommand.cs # git-cli files
Program.cs # Entry point with DI/logging setup
eng/
scripts/
install-cli.bat # Pack and install the tool globally
dotnet build