by octadira
Per-folder Git source control with GitHub and Forgejo support — manage a separate Git repository for each folder in your vault.
Folder Git
Folder Git brings VS Code-style Git source control to Obsidian. Unlike plugins that treat the whole vault as a single repository, Folder Git lets you manage multiple independent Git repositories, one per folder. It works with GitHub and Forgejo / Gitea (including Codeberg and self-hosted instances).
Features
- One repository per folder. Track any number of folders (or the vault root) as separate Git repositories, each with its own remote, branch and backup schedule.
- Source Control panel. Repository list with change indicators, current branch with ahead/behind counts, and staged, changed, untracked and conflicted files.
- Everyday Git operations.
- Stage, unstage and discard individual files or everything at once. Discarding always asks for confirmation.
- Commit staged changes, or stage everything and commit in one click. Press
Ctrl/Cmd+Enterto commit. An empty message falls back to the repository's commit template. - Push, pull, sync (pull then push) and fetch. The first push sets the upstream branch automatically.
- Colored diffs for working-tree and staged changes.
- Resolve merge conflicts: keep your version or the incoming one per file (with confirmation), or edit the file and mark it as resolved. A banner shows while a merge is in progress and lets you abort it.
- Branches. Click the branch name to switch. The ⋯ menu and command palette also create, merge and delete branches. Remote-only branches can be checked out as tracking branches. Deleting a branch that is not fully merged asks before forcing it.
- Stash. Stash all changes (untracked files included) with an optional note. Stashes are listed in the panel with apply, pop and delete.
- Fix the last commit. Amend last commit changes its message and adds whatever is staged. Undo last commit moves it back to the staged area. Both warn when the commit was already pushed.
- History view. Browse commits per repository, 50 at a time with Load older commits, and open the diff of any file changed in a commit. Limit it to a single file (renames are followed) from the file's context menu or the Open history of current file command. In an expanded commit, Restore this version puts a file back to how it was in that commit (left unstaged so you can review it).
- Status bar. Branch, ahead/behind counts and pending changes of the current repository. Click it to open Source Control. It turns red when the last push, pull, sync or auto-commit failed.
- Sync errors. A failed push, pull, sync or background auto-commit/auto-push is shown as a warning on the repository in the Source Control panel, with the error message, until the next success. Background failures notify once, not on every interval.
- GitHub and Forgejo integration.
- Validate an access token and see which account is connected.
- Create a new remote repository while adding a folder: under your account or one of your organizations, private or public.
- Forgejo: create a new organization from the same dialog.
- Clone private repositories over HTTPS.
- Auto-backup. Per-repository auto-commit interval, commit message template (placeholders such as
{{date}},{{branch}}and{{files}}) and auto-push after every commit. Failures are shown in the panel and the status bar. .gitignoretools. Built-in.gitignoreeditor, plus Add to / Remove from .gitignore in the file explorer context menu.- Context menu. Right-click a folder to add it as a repository. On a repository root folder you can open Source Control or History, pull, push, or edit
.gitignore.
Requirements
- Obsidian 1.7.2 or later, desktop only (Windows, macOS, Linux).
- Git installed and available on your
PATH, or its location set in the plugin settings.
Installation
From Community Plugins (recommended)
- Open Settings → Community plugins and turn off Restricted mode if needed.
- Select Browse and search for Folder Git.
- Select Install, then Enable.
Manual installation
- Download
main.js,manifest.jsonandstyles.cssfrom the latest release. - Copy them into
<your vault>/.obsidian/plugins/folder-git/. - Reload Obsidian and enable Folder Git in Settings → Community plugins.
Getting started
Add a repository
- Run Folder Git: Add folder repository from the command palette, or right-click a folder and choose Git: add repository.
- Select the folder to track.
- Choose a mode:
- Use existing repo: the folder already contains a
.gitrepository. Its remote is detected automatically. - Initialize new repo: runs
git initin the folder. - Clone from URL: clones into a new subfolder, or directly into the selected folder if it is empty.
- Use existing repo: the folder already contains a
- Optionally, for existing or new repositories, choose Create remote repository on GitHub or Forgejo. Then pick the Owner: your account, one of your organizations, or (on Forgejo) a new organization.
- Select Add repository.
Source Control view
Open it from the ribbon icon or with Folder Git: Open source control.
- Click a repository in the list to switch to it. The dot and counter show pending changes.
- Header buttons: Refresh, Pull, Push, Sync, and a ⋯ menu with Fetch, Open history, Edit
.gitignore, branch actions (switch, new, merge, delete), Stash, Amend / Undo last commit and Add folder repository. Click the branch name to switch branch. - On each file:
+stages,−unstages,↩discards, and the file icon opens the note. Click the row to view its diff, or right-click for more actions.
Commands
| Command | Description |
|---|---|
| Open source control | Open the Source Control panel |
| Open Git history | Open the History view for a repository |
| Open history of current file | Open the History view limited to the file you are editing |
| Switch branch / New branch / Stash changes (active repo) | Branch and stash actions from the command palette |
| Add folder repository | Start tracking a folder |
| Commit (active repo) | Focus the commit message box |
| Commit all changes with default message (active repo) | Stage everything and commit using the template (and push if auto-push is on) |
| Push / Pull / Sync / Fetch (active repo) | Network operations |
| Edit .gitignore | Open the .gitignore editor |
The active repo is the one containing the file you are editing. Otherwise it is the one selected in the Source Control panel. If that is still ambiguous, you are asked to pick one.
Settings
General
| Setting | Default | Description |
|---|---|---|
| Git binary path | (empty) | Path to the git executable. Leave empty to use the one on your PATH. Takes effect after reloading the plugin. |
| Show untracked files | On | Show untracked files in the Source Control panel. |
| Status refresh interval | 30 s | How often git status runs for each repository. 0 turns auto-refresh off. |
Per repository (under Configured repositories)
| Setting | Description |
|---|---|
| Remote URL | Applied to the repository's remote when you leave the field. |
| Auto-push after commit | Push after every commit made from the plugin, manual or automatic. On by default when the repository has a remote. |
| Auto-commit interval | Minutes between automatic stage all + commit. 0 disables it. |
| Commit message template | Used by auto-commit and when the commit message is empty. Placeholders: {{date}} (ISO date), {{time}} (local HH:MM), {{repo}} (folder, or the vault name for the vault root), {{branch}} and {{files}} (number of files in the commit). |
| Remove | Stops tracking the folder. The .git folder and your files are left untouched. |
Authentication
Tokens are only needed to create remote repositories and to push, pull or clone over HTTPS. SSH remotes keep using your SSH keys and need no token.
GitHub
- Create a personal access token:
- Classic token:
reposcope. Addread:orgif you want your private organization memberships listed. - Fine-grained token: Contents and Administration read and write permissions. To create new repositories the token needs access to All repositories. For organization repositories, set the organization as the token's Resource owner.
- Classic token:
- In Settings → Folder Git → GitHub, paste the token and select Validate.
Forgejo / Gitea / Codeberg
- In Settings → Folder Git → Forgejo, enter your instance URL, for example
https://codeberg.orgorhttps://git.example.com. - On your instance, open Settings → Applications and generate an access token with:
repository: read and writeuser: readorganization: read (to list your organizations), or read and write (to also create organizations)
- Paste the token and select Validate.
Privacy and security
Where tokens are stored
Tokens are saved unencrypted in the plugin's settings file: <vault>/.obsidian/plugins/folder-git/data.json. Anything that copies that file copies your tokens.
- Vault root as a repository. Commit all and auto-commit stage everything, including
.obsidian/. When you add the vault root as a repository, the plugin adds.obsidian/plugins/folder-git/data.jsonto the vault's.gitignore(unless Git already ignores it). It also warns you if the file is already committed; in that case rungit rm --cachedon it and revoke the tokens if you pushed it. - Other sync tools. Obsidian Sync (when Installed community plugins sync is on), iCloud, Dropbox and similar tools copy
data.jsonto your other devices. Exclude the file, or accept that the token lives there too. - Least privilege. Use a fine-grained or narrowly scoped token with an expiry date, and revoke it if the file ever leaks.
How tokens are used
- API calls. When you validate a token, create a repository or organization, or list organizations, the token is sent in the
Authorizationheader toapi.github.comor to<your Forgejo instance>/api/v1. It is never put in a URL. - Git operations. During push, pull, sync, fetch and clone, the token is handed to that one Git process through environment variables. A credential helper passed on the command line (
-c credential.helper=…) reads them. Nothing is written to.git/config, to a credentials file or to the remote URL. - Host matching. A token is only offered to an
https://remote whose host (and port) exactly matchesgithub.comor your Forgejo instance. Other remotes never see it. - Other credential helpers. For matching hosts, the plugin's helper replaces any configured helper (such as Git Credential Manager or the macOS keychain) for that command. For every other host, your normal Git configuration applies.
- No prompts. Network operations run with
GIT_TERMINAL_PROMPT=0, so Git fails instead of waiting for a password it cannot ask for. - Process environment. While a network operation runs, the token is in the Git process's environment. Other programs running as your user could read it there.
- SSH remotes use your SSH keys and agent. The plugin never sends a token over SSH.
Plain http://
Tokens are never sent to http:// remotes, with one exception. If you configure a Forgejo instance on http://, its http:// remotes receive the token unencrypted, and the plugin warns you when you validate it.
Network access
The plugin only connects to api.github.com, the Forgejo instance you configure, and the Git remotes of your repositories. There is no telemetry, analytics or update check.
Local changes
- The plugin runs Git only in the folders you add, plus
git cloneinto the folder you choose. - It writes
.gitignoreonly when you use the.gitignoreeditor or the Add to / Remove from .gitignore actions. - Git runs with your environment, so variables such as
GIT_SSH_COMMAND,EDITORorGIT_ASKPASSapply exactly as they do in a terminal.
Upgrading from 1.0.x
Versions up to 1.0.4 stored the GitHub token in a plaintext .git-credentials file in the plugin folder and pointed each repository's credential.helper at it. From 1.1.0 on, the plugin deletes that file when it loads and removes that credential.helper entry from each repository when it opens it.
If that file was ever synced, backed up or committed, revoke the old token and create a new one.
Troubleshooting
| Problem | Fix |
|---|---|
| "… is not a Git repository root" | The selected folder must contain its own .git directory. Use Initialize new repo or pick the repository's top folder. |
| Git not found | Install Git, or set Git binary path in settings (reload the plugin afterwards). |
| Push asks for credentials or fails with 401/403 | Validate the matching token in settings and check its permissions. For other hosts, use SSH or your system's Git credential manager. |
| "No commits yet — commit before pushing" | Make the first commit before pushing. |
| Push fails on a host that matches your token, even though Git Credential Manager has valid credentials | For matching hosts only the plugin's token is used. Validate a working token, or switch the remote to SSH. |
| Organizations are not listed | Grant the token organization read access (Forgejo) or read:org (GitHub classic), then press the reload button next to Owner. |
Limitations
- Desktop only. Git runs as an external process, which Obsidian mobile does not support.
- Conflicts are resolved per file: keep one side wholesale, or edit the file yourself and mark it as resolved. There is no side-by-side merge editor. If your Git is configured to pull with rebase, my version and incoming version swap meaning during the rebase.
- Amending or undoing a commit that was already pushed needs a force push, which the plugin does not do; use a terminal.
- Branch rename, rebase, tags and partial (per-hunk) staging are not available.
- Restoring a file from before it was renamed recreates it at its old path.
- Tokens can be stored for one GitHub account and one Forgejo instance. Other HTTPS hosts rely on your system's Git credential setup.
Contributing
Bug reports and pull requests are welcome. See CONTRIBUTING.md for the development setup and release process, and CHANGELOG.md for version history.
License
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.