Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Coder

A CLI tool for syncing git repositories between local and remote servers using git bundles.

This tool is useful when you need to sync code with a remote server that doesn't have direct git remote access (e.g., air-gapped environments, restricted networks).

## Installation

```bash
cargo install --path .
```

## Usage

### Sync

Sync local repository with a git bundle file:

```bash
coder sync <BUNDLE>
```

This command will:
- Parse branches from the bundle file
- Remove local branches that don't exist in the bundle
- Add new branches from the bundle
- Update all branches with changes from the bundle

### Push

Push local repository to a remote server:

```bash
coder push <SSH_URL> <DIRECTORY>
```

This command will:
1. Create a git bundle from all local branches
2. Transfer the bundle to the remote server via SCP
3. Run `coder sync` on the remote server
4. Clean up temporary files

### Pull

Pull repository from a remote server:

```bash
coder pull <SSH_URL> <DIRECTORY>
```

This command will:
1. Create a git bundle on the remote server
2. Transfer the bundle to local via SCP
3. Run sync locally to update branches
4. Clean up temporary files

## Shell Completion

Generate shell completion scripts:

```bash
coder --generate <bash|zsh|fish> > shell init script
```

## Requirements

- Git
- SSH/SCP (for push/pull commands)
- `coder` must be installed on the remote server (for push command)
25 changes: 21 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,36 @@ enum MainError {

#[derive(Subcommand)]
enum Commands {
/// Sync code with git bundle file
/// Sync local repository with a git bundle file
#[command(
long_about = "Update local branches to match the bundle. Removes branches not in bundle, adds new branches, and updates existing ones."
)]
Sync(Sync),
/// Push code to remote server with git bundle file

/// Push local repository to a remote server
#[command(
long_about = "Create a git bundle from all local branches, transfer it to the remote server via SCP, and run sync on the remote."
)]
Push(Push),
/// Pull code from remote server with git bundle file

/// Pull repository from a remote server
#[command(
long_about = "Create a git bundle on the remote server, transfer it locally via SCP, and sync local branches."
)]
Pull(Pull),
}

#[derive(Parser)]
#[command(
version,
about = "Sync git repositories via bundles over SSH",
long_about = "A CLI tool for syncing git repositories between local and remote servers using git bundles.\nUseful for air-gapped environments or restricted networks without direct git remote access."
)]
struct Cli {
/// Generate shell completion
/// Generate shell completion script
#[arg(long, value_enum)]
generate: Option<Shell>,

#[command(subcommand)]
commands: Option<Commands>,
}
Expand Down