Skip to content

CLI & Environment Variables ​

Besides the graphical interface inside Microsoft Word and WPS Writer, the Rust binary wordgit that ships with WordGit (wordgit.exe on Windows) is a full command-line tool in its own right. Use it for quick lookups in the terminal, batch scripting and automation, maintenance in offline environments, and API-level troubleshooting. Like the graphical interface, its messages follow the interface language chosen in Settings.

Executable Location ​

Operating systemDefault binary path after installation
Windows%LOCALAPPDATA%\WordGit\app\wordgit.exe
Linux~/.local/share/WordGit/app/wordgit
macOS~/Library/Containers/com.kingsoft.wpsoffice.mac/Data/WordGit/app/wordgit

Calling it from the terminal

Add the app folder above to your system PATH environment variable, or define an alias in PowerShell / your shell, and you can run wordgit directly from any document folder.


Common Document History Commands ​

You can inspect or commit any .docx straight from the terminal, without opening Word or WPS:

sh
# Show the current branch, whether the working document is clean, the latest commit and remote sync status (structured JSON output)
wordgit status thesis.docx

# List the document's full commit history and graph information
wordgit log thesis.docx

# Create a new commit directly from the document as saved on disk (an author name can be specified; a commit author set in Settings takes precedence)
wordgit commit thesis.docx -m "Add experiment comparison table to Chapter 4" --author "Alice"

# Show the core engine version
wordgit version

Installation, Service and Maintenance Commands ​

Command syntaxPurpose
wordgit serve [--port N]Starts the local HTTP service in the foreground (listens on 127.0.0.1 only, default port 47821, and writes a random auth token to service.json)
wordgit install [--addin <dir>] [--no-autostart]Deploys the WPS Writer JS add-in, registers autostart at login for the current user and starts the local service (with --no-autostart, the login autostart registration is skipped)
wordgit uninstallStops the service and removes the WPS add-in and autostart configuration; all history repositories and review drafts are kept
wordgit data-directory [absolute-path]Without an argument, prints the current history data folder; with a new absolute path while the service is stopped, verifies and moves repositories (while the service is running, move it under Settings → Storage on the ribbon instead)
wordgit git statusPrints the Git path, version and source currently in use (system Git / bundled MinGit / WORDGIT_GIT), plus the status of the pinned bundled MinGit version
wordgit git install [--archive <file>] [--force]Windows only: if no Git 2.46+ is installed, automatically downloads a slim MinGit from a mirror in mainland China, verifies it and installs it; in offline environments use --archive MinGit.zip to install from a local archive; --force forces a reinstall of the bundled MinGit

Advanced Debugging: Calling the Core API Directly with wordgit call ​

wordgit call <endpoint> [JSON arguments] runs exactly the same core operation as the HTTP service, in-process, and prints the returned JSON. It is ideal for automation scripts and in-depth troubleshooting:

sh
# Show the service environment and a Git overview
wordgit call info '{}'

# Show the semantic change summary between a document and the latest (or a given) commit (counts of sections, paragraphs, tables and comments)
wordgit call version/diff-summary '{"document":"D:/Thesis/thesis.docx"}'

# Create a new branch from the current HEAD
wordgit call branch/create '{"document":"D:/Thesis/thesis.docx","name":"journal-v2"}'

# List Git status badges for every document in the folder (the data source of the left Project pane)
wordgit call workspace/list '{"folder":"D:/Thesis"}'

# Show the overall status of a multi-document project
wordgit call project/status '{"folder":"D:/Thesis"}'

# Show the settings shared by Word and WPS (interface language, commit author, reminder, AI summary and so on; the API key is never printed)
wordgit call settings/get '{}'

# Test error classification and troubleshooting-hint generation
wordgit call ui/hint '{"message":"The process cannot access the file because it is being used by another process."}'

Supported Environment Variables ​

You can customize WordGit's runtime folder and underlying tool paths through user environment variables:

Environment variablePlatformsEffect
WORDGIT_HOMEWindows / Linux / macOSOverrides the default runtime root folder (which holds service.json, settings.json, sessions, logs, and the default repositories unless it has been moved separately). Commonly used for isolated multi-environment testing or portable deployments
WORDGIT_GITWindows / Linux / macOSExplicitly sets the absolute path of the git executable to use (git.exe on Windows); takes precedence over the system PATH and the bundled MinGit
WORDGIT_SERVICE_EXEWindows (Word add-in)Explicitly sets the path of the wordgit.exe that the Word add-in uses when it automatically starts the local service (mainly for development and integration debugging)

Git lookup order

When the core engine starts or performs an operation, it locates Git in this order:

  1. The absolute path given by the WORDGIT_GIT environment variable;
  2. A system-installed Git 2.46+;
  3. The isolated MinGit that WordGit downloaded automatically or installed offline into its runtime folder;
  4. An older system Git below 2.46 (as a compatibility fallback).

Released under the GPL-3.0-only license · WordGit brings Git version control to local documents · Disclaimer