Skip to main content

Overview

Chapi Assistant provides a full-featured Git management system integrated directly into your development workflow. Manage commits, branches, stashes, and remote repositories without leaving your IDE.
All Git operations are built on top of LibGit2Sharp with validation, error handling, and user notifications.

Commit Management

Making Commits

Commit changes with automatic validation and notifications:
var request = new CommitRequest
{
    ProjectPath = @"C:\Projects\MyApp",
    Message = "Add customer creation feature",
    Files = new[] { "Customer.cs", "CustomerRepository.cs" }
};

var result = await commitChangesUseCase.ExecuteAsync(request);
Commit specific files with a message:
var request = new CommitRequest
{
    ProjectPath = projectPath,
    Message = "Fix validation bug in customer form",
    Files = new[] { 
        "Views/CustomerView.xaml",
        "ViewModels/CustomerViewModel.cs" 
    }
};

var result = await commitChangesUseCase.ExecuteAsync(request);

if (result.IsSuccess)
{
    var commit = result.Value;
    Console.WriteLine($"Committed: {commit.Sha}");
}

Commit Validation

  • ProjectPath: Must be a valid, existing directory
  • Message: Cannot be empty or whitespace
  • Files: Must contain at least one file
  • Success: “Commit realizado:
  • Error: “Error al hacer commit:
  • Warning: Validation failures

Branch Operations

Creating Branches

var result = await createBranchUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp",
    branchName: "feature/customer-search",
    fromCommitOrBranch: "develop" // Optional
);
projectPath
string
required
Path to the Git repository.
branchName
string
required
Name of the new branch to create.
fromCommitOrBranch
string
Optional commit SHA or branch name to create from. Defaults to HEAD.
Create a branch from the current commit:
await createBranchUseCase.ExecuteAsync(
    projectPath,
    "feature/new-feature"
);
// Creates from HEAD

Switching Branches

var result = await switchBranchUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp",
    branchName: "develop"
);

Listing Branches

var branches = await getBranchesUseCase.ExecuteAsync(projectPath);

foreach (var branch in branches)
{
    Console.WriteLine(branch);
}

Stash Management

Stashing Changes

Temporarily save changes without committing:
var result = await stashChangesUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp",
    message: "WIP: Customer search feature",
    files: null // null = stash all changes
);
Stash all uncommitted changes:
await stashChangesUseCase.ExecuteAsync(
    projectPath,
    "Saving work before branch switch"
);

Stash Operations

Stash Pop

Apply and remove the latest stash:
await stashPopUseCase.ExecuteAsync(
    projectPath,
    index: 0
);

Stash Drop

Remove a stash without applying:
await stashDropUseCase.ExecuteAsync(
    projectPath,
    index: 0
);

Stash Clear

Remove all stashes:
await stashClearUseCase.ExecuteAsync(
    projectPath
);

Remote Operations

Push Changes

Push commits to remote repository:
var result = await pushChangesUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp",
    branch: "main"
);
Success notification: “Push exitoso a

Pull Changes

Fetch and merge changes from remote:
var result = await pullChangesUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp",
    branch: "main",
    stashChanges: true // Auto-stash local changes
);
Pull without stashing:
await pullChangesUseCase.ExecuteAsync(
    projectPath,
    "main",
    stashChanges: false
);

Fetch Changes

var result = await fetchChangesUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp"
);

History & Diff Operations

View Commit History

var history = await loadHistoryUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp"
);

foreach (var commit in history)
{
    Console.WriteLine($"{commit.Sha}: {commit.Message}");
}

View File Differences

var diff = await getFileDiffUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp",
    filePath: "Customer.cs"
);

Get Commit Statistics

var stats = await getCommitStatsUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp",
    commitSha: "a1b2c3d4"
);

Console.WriteLine($"Files changed: {stats.FilesChanged}");
Console.WriteLine($"Insertions: {stats.Insertions}");
Console.WriteLine($"Deletions: {stats.Deletions}");

Files Changed in Commit

var files = await getFilesChangedInCommitUseCase.ExecuteAsync(
    projectPath,
    commitSha
);

Tag Management

var result = await createTagUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp",
    tagName: "v1.0.0",
    message: "Release version 1.0.0"
);

Change Management

Load Changes

var changes = await loadChangesUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp"
);

foreach (var change in changes)
{
    Console.WriteLine($"{change.Status}: {change.FilePath}");
}

Discard Changes

var result = await discardChangesUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp",
    files: new[] { "Customer.cs" }
);
Discarding changes is irreversible. Ensure you want to lose the modifications before proceeding.

Reset Commit

var result = await resetCommitUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp",
    commitSha: "a1b2c3d4",
    resetType: ResetMode.Mixed // Soft, Mixed, or Hard
);

Repository Association

Associate Remote Repository

var result = await associateGitUseCase.ExecuteAsync(
    projectPath: @"C:\Projects\MyApp",
    remoteUrl: "https://github.com/myorg/myapp.git"
);

Error Handling

// Common validation errors
if (!result.IsSuccess)
{
    switch (result.Error)
    {
        case "Ruta de proyecto invalida":
            // Invalid project path
            break;
        case "El proyecto no existe":
            // Project directory doesn't exist
            break;
        case "Nombre de rama invalido":
            // Invalid branch name
            break;
    }
}

Best Practices

  • Write clear, concise commit messages
  • Use imperative mood (“Add feature” not “Added feature”)
  • Keep first line under 50 characters
  • Add detailed description if needed
  • Use prefixes: feature/, bugfix/, hotfix/
  • Keep names lowercase with hyphens
  • Be descriptive: feature/customer-search
  • Include ticket numbers: bugfix/PROJ-123-fix-validation
  • Always add descriptive stash messages
  • Use auto-stash when pulling with local changes
  • Clean up old stashes regularly
  • Pop stashes as soon as possible
  • Pull before starting new work
  • Push frequently to backup work
  • Fetch regularly to stay updated
  • Resolve conflicts promptly

AI Assistant

Generate commit messages automatically with AI

Project Creation

New projects come with Git initialized and configured

Build docs developers (and LLMs) love