Skip to content

Commit f6cdf0f

Browse files
committed
Initial commit: Auto Git Commit plugin for Obsidian
0 parents  commit f6cdf0f

File tree

13 files changed

+1281
-0
lines changed

13 files changed

+1281
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Auto Git Commit
2+
3+
An Obsidian plugin that automatically commits vault changes to git.
4+
5+
## Features
6+
7+
- **Auto Commit**: Automatically commit changes after file modifications (with debounce)
8+
- **Manual Commit**: Commands for manual commit and push
9+
- **Auto Push**: Optionally push to remote after commit
10+
- **Custom Template**: Configurable commit message with variables
11+
- **File List**: Optionally include changed file list in commit body
12+
- **i18n**: English and Chinese UI support
13+
14+
## Installation
15+
16+
### Manual Installation
17+
18+
1. Download `main.js` and `manifest.json` from releases
19+
2. Create folder `.obsidian/plugins/auto-git-commit/` in your vault
20+
3. Copy downloaded files into the folder
21+
4. Enable the plugin in Obsidian settings
22+
23+
### Build from Source
24+
25+
```bash
26+
cd .obsidian/plugins/auto-git-commit
27+
npm install
28+
npm run build
29+
```
30+
31+
## Commands
32+
33+
| Command | Description |
34+
|---------|-------------|
35+
| `Auto Git Commit: Commit now` | Commit all changes immediately |
36+
| `Auto Git Commit: Commit and push` | Commit and push to remote |
37+
38+
## Settings
39+
40+
| Option | Description | Default |
41+
|--------|-------------|---------|
42+
| Enable auto commit | Auto commit after file changes | Off |
43+
| Debounce delay (seconds) | Wait time before committing | 30 |
44+
| Auto push after commit | Push to remote after commit | Off |
45+
| Commit message template | Custom message format | `vault backup: {{date}} {{time}}` |
46+
| Include file list in commit body | List changed files in body | Off |
47+
| Git binary path | Path to git executable | `git` |
48+
| Ignore .obsidian directory | Exclude config folder from triggers | On |
49+
50+
## Template Variables
51+
52+
| Variable | Description | Example |
53+
|----------|-------------|---------|
54+
| `{{date}}` | ISO date | `2025-12-20` |
55+
| `{{time}}` | Time (HH:MM:SS) | `10:30:00` |
56+
| `{{files}}` | Changed files (max 5) | `a.md, b.md, ...` |
57+
| `{{count}}` | Number of changed files | `3` |
58+
59+
## Example Commit
60+
61+
With "Include file list" enabled:
62+
63+
```
64+
vault backup: 2025-12-20 10:30:00
65+
66+
notes/daily/2025-12-20.md
67+
attachments/image.png
68+
templates/note.md
69+
```
70+
71+
## Requirements
72+
73+
- Obsidian 1.2.0+
74+
- Desktop only (git not available on mobile)
75+
- Git installed and accessible
76+
77+
## License
78+
79+
MIT

esbuild.config.mjs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import esbuild from "esbuild";
2+
import process from "process";
3+
import builtins from "builtin-modules";
4+
5+
const prod = process.argv[2] === "production";
6+
7+
const context = await esbuild.context({
8+
entryPoints: ["src/main.ts"],
9+
bundle: true,
10+
external: [
11+
"obsidian",
12+
"electron",
13+
"@codemirror/autocomplete",
14+
"@codemirror/collab",
15+
"@codemirror/commands",
16+
"@codemirror/language",
17+
"@codemirror/lint",
18+
"@codemirror/search",
19+
"@codemirror/state",
20+
"@codemirror/view",
21+
"@lezer/common",
22+
"@lezer/highlight",
23+
"@lezer/lr",
24+
...builtins,
25+
],
26+
format: "cjs",
27+
target: "es2018",
28+
logLevel: "info",
29+
sourcemap: prod ? false : "inline",
30+
treeShaking: true,
31+
outfile: "main.js",
32+
minify: prod,
33+
});
34+
35+
if (prod) {
36+
await context.rebuild();
37+
process.exit(0);
38+
} else {
39+
await context.watch();
40+
}

main.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifest.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"id": "auto-git-commit",
3+
"name": "Auto Git Commit",
4+
"version": "1.0.0",
5+
"minAppVersion": "1.2.0",
6+
"description": "Automatically commit vault changes to git with customizable triggers and templates.",
7+
"author": "small",
8+
"isDesktopOnly": true
9+
}

0 commit comments

Comments
 (0)