Files
unity-git-auto-syncd/net.lenrui.git-auto-sync/README.md
T
2026-11-05 23:16:37 -08:00

37 lines
2.5 KiB
Markdown

# Git Auto Sync
Keeps a Unity project in step with its git remote.
- **When the Editor opens:** fetches. If the branch's upstream has new commits, it updates to them. Unpushed local commits are rebased on top, and uncommitted files are stashed and restored. If an uncommitted edit touches a file that also changed remotely, the pull is skipped and the files are listed, so no conflict markers end up in scenes or prefabs.
- **When the Editor closes:** saves scenes and assets, commits everything in the Unity project folder, brings in anything pushed meanwhile, then pushes. A branch with no upstream is pushed with `-u`.
If something can't be done safely (a conflict, no network, a failed push), it asks whether to **Quit Anyway** or **Stay Open**. Your work is always committed locally first, and an unpushed commit goes up the next time you close.
## Install
**Embedded:** copy the `net.lenrui.git-auto-sync` folder into the project's `Packages/` folder. It becomes part of the project and is committed along with it.
**From git:** put this folder in its own repository, then in Unity open **Window > Package Manager > + > Add package from git URL...** and enter the repository URL, for example `https://git.lenrui.net/<owner>/git-auto-sync.git`. If the package sits in a subfolder of a repository, add `?path=/that/subfolder` to the URL.
## Requirements
- Unity 2019.4 or newer, and `git` on the PATH.
- Git credentials that work without typing anything: an SSH key loaded in an agent, or a credential manager for HTTPS. The Editor can't show git's password prompts.
- `Library/` must be ignored by git, or the tool refuses to commit. If the Unity project is in a subfolder of the repository, note that Unity's usual `/[Ll]ibrary/` pattern only matches next to the `.gitignore` it's in: keep that `.gitignore` inside the Unity project folder, or use `[Ll]ibrary/` at the repository root.
## Menu
**Tools > Git Auto Sync**
- **Enabled**: on by default.
- **Ask Before Committing on Close**: off by default, so closing commits and pushes without a prompt.
- **Pull Latest Now** and **Commit and Push Now**: run either half by hand.
Settings are stored per project, per machine.
## What gets committed
Only the Unity project folder (the folder containing `Assets/`). Other files elsewhere in the repository are left alone. Pulls and pushes act on the whole branch as usual.
Commit messages look like `Auto-commit from Unity (MACHINE, 2026-11-05 22:27)`, followed by the list of changed files.