| Crates.io | gitwatch-rs |
| lib.rs | gitwatch-rs |
| version | 0.1.1 |
| created_at | 2024-12-23 21:19:30.344001+00 |
| updated_at | 2025-07-31 20:00:01.60051+00 |
| description | CLI to watch a git repo and automatically commit changes |
| homepage | |
| repository | https://github.com/croissong/gitwatch-rs |
| max_upload_size | |
| id | 1493425 |
| size | 218,448 |
A Rust implementation of the original gitwatch script - with a few additional features.
Watch a local Git repository and automatically commit changes
Optionally push to a remote
Use a custom commit message or generate one via a script
Configure a debounce time to limit commit frequency
Basic usage:
gitwatch watch /path/to/repo --commit-message "Auto commit"
I use gitwatch to watch my local notes repository and generate commit messages using aichat.
The example folder contains a small repository demonstrating this use case:

❯ gitwatch watch --help
Watch a repository and commit changes
Usage: gitwatch watch [OPTIONS] [REPOSITORY]
Arguments:
[REPOSITORY] Path to the Git repository to monitor for changes [default: .]
Options:
-m, --commit-message <MESSAGE>
Static commit message to use for all commits
--commit-message-script <SCRIPT>
Path to executable script that generates commit messages.
The path can be absolute or relative to the repository.
The script is executed with the repository as working directory
and must output the message to stdout.
--commit-on-start <COMMIT_ON_START>
Automatically commit any existing changes on start [default: true] [possible values: true, false]
--debounce-seconds <DEBOUNCE_SECONDS>
Number of seconds to wait before processing multiple changes to the same file.
Higher values reduce commit frequency but group more changes together. [default: 1]
--dry-run
Run without performing actual Git operations (staging, committing, etc.)
-i, --ignore-regex <IGNORE_REGEX>
Regular expression pattern for files to exclude from watching.
Matching is performed against repository-relative file paths.
Note: the .git folder & gitignored files are ignored by default.
Example: "\.tmp$" to ignore temporary files.
--log-level <LOG_LEVEL>
Set the log level [default: info] [possible values: trace, debug, info, warn, error]
-r, --remote <REMOTE>
Name of the remote to push to (if specified).
Example: "origin".
--retries <RETRIES>
Number of retry attempts when errors occur.
Use -1 for infinite retries. [default: 3]
-w, --watch <WATCH>
Enable continuous monitoring of filesystem changes.
Set to false for one-time commit of current changes. [default: true] [possible values: true, false]
-h, --help
Print help
Most options can also be configured in a gitwatch.yml file located at the root of the watched repository.
See docs/gitwatch.example.yaml for reference.
If you've enabled gpgsign globally, you might want to disable it for the watched repositories, since gitwatch uses your regular git user to create the commits.
.gitconfig file to your local gitconfig:
# cd /path/to/repo
git config --local include.path ../.gitconfig
[commit]
gpgsign = false
Create a systemd user service file gitwatch@.service:
[Unit]
Description=Watch a Git repository and automatically commit changes
[Service]
ExecStart=/usr/local/bin/gitwatch watch %I
ExecStop=/bin/true
[Install]
WantedBy=default.target
I recommend you use it in combination with a config file, then you only need to pass the repo dir as argument:
systemctl --user start gitwatch@$(systemd-escape /path/to/repo/).service
There's also a Nix module, which provides a home-manager service:
inputs = {
gitwatch-rs.url = "github:croissong/gitwatch-rs";
};
...
imports = [ inputs.gitwatch-rs.modules.gitwatch ];
services.gitwatch = {
notes = {
repo_path = "${config.home.homeDirectory}/notes/";
args = [ "--log-level=debug" ];
extraPackages = with pkgs; [
bash
coreutils
git
aichat
];
};
}
A flake.nix is available for Nix:
inputs = {
gitwatch-rs.url = "github:croissong/gitwatch-rs";
};
# Reference the package as `inputs.gitwatch-rs.packages.<system>.default`
}
# TODO: Add AUR package installation instructions
# TODO: Add Ubuntu package installation instructions
Docker images are published to the ghcr.io/croissong/gitwatch-rs:
docker run -v /path/to/repo:/repo ghcr.io/croissong/gitwatch-rs:latest /repo
Precompiled binaries are available for Linux and macOS from releases.
Shell completion scripts for bash, zsh, fish & more can be generated via:
gitwatch completion <SHELL>
This is a Rust implementation of the original gitwatch bash script.
Contributions are welcome! Feel free to submit a Pull Request.
See CONTRIBUTING.md for development hints.