跳到主要内容

CLI User Guide

AtomGit CLI is a command-line tool for interacting with the AtomGit platform, supporting operations such as uploading and downloading models and datasets. The tool is developed based on the OpenMind Hub SDK and is configured to connect to the AtomGit API endpoint.

Features

  • User authentication and login management
  • Git Integration: Automatically configure Git credentials, support standard Git commands
  • Support for creating model and dataset repositories
  • Batch upload of files and directories
  • Download repository content
  • Colorful terminal output
  • Upload and download progress display
  • Configuration file management

Installation

Install from source

git clone https://gitcode.com/gitcode-ai/gitcode_cli.git
cd gitcode_cli
pip install -e .

Install using pip

pip install gitcode

Usage

1. Login

First, you need to log in to the AtomGit platform:

gitcode login

The system will prompt you to enter an access token (obtained from the AtomGit platform).

Git Integration Feature: After successful login, the tool will automatically configure the Git credential helper, allowing you to directly use standard Git commands to operate AtomGit repositories without re-entering the token. The credential helper will automatically retrieve your real username from the AtomGit API for Git authentication:

# After logging in, these Git commands will automatically use the saved token
# Supports two domain name formats
git clone https://gitcode.com/username/repo-name.git
git clone https://hub.gitcode.com/username/repo-name.git
git push origin main
git pull origin main

2. Upload Files

Upload Model

gitcode upload ./your-model-dir --repo-id your-username/your-model-name

Upload Dataset

gitcode upload ./your-dataset-dir --repo-id your-username/your-dataset-name

Upload a Single File

gitcode upload ./model.bin --repo-id your-username/your-model-name

3. Download Files

Download to Current Directory

gitcode download your-username/your-model-name

Download to a Specific Directory

gitcode download your-username/your-model-name -d ./models/

4. Other Commands

Logout

gitcode logout

Show Configuration Information

gitcode config-show

Configuration File

The configuration file is stored at ~/.gitcode/config.json, containing user authentication information and other settings.

API Endpoint Configuration

The tool is pre-configured to connect to the AtomGit platform API endpoint:

  • API Endpoint: https://hub.gitcode.com
  • Environment Variable: OPENMIND_HUB_ENDPOINT=https://hub.gitcode.com

This configuration is automatically set when the program starts, and users do not need to configure it manually.

Detailed Explanation of Git Integration

Automatic Configuration

When you successfully log in using gitcode login, the tool automatically configures Git credentials, allowing you to directly use standard Git commands to operate AtomGit repositories.

Supported Git Operations

After logging in, you can directly use the following Git commands without manually entering the token:

# Clone a repository (supports two domain name formats)
git clone https://gitcode.com/username/repo-name.git
git clone https://hub.gitcode.com/username/repo-name.git

# Push code
git push origin main

# Pull updates
git pull origin main

# Add a remote repository
git remote add origin https://gitcode.com/username/repo-name.git

Security

  • Credential configuration only takes effect for gitcode.com and hub.gitcode.com domains
  • Token is securely stored in the local configuration file
  • Does not affect the authentication configuration of other Git repositories
  • Automatically clears credential configuration when gitcode logout is executed

Notes

  • Supported URL formats: https://gitcode.com/... or https://hub.gitcode.com/...
  • If Git commands still require entering a password, re-login: gitcode logout followed by gitcode login

Error Handling

  • If a network error occurs, the tool will automatically retry
  • A progress bar is displayed when uploading large files
  • All operations have detailed error message prompts

Supported File Types

  • Supports upload and download of all file types
  • Automatically handles directory structure
  • Supports large file transfer