Why people search for Clash profile backup and YAML rollback

A working Clash or Mihomo (the engine still labeled Clash Meta in many clients) profile is the sum of thousands of tiny decisions: bypass lists, policy-group ordering, DNS modes, optional TUN interfaces, remote rule providers, and subscription imports that change whenever the operator rotates endpoints. The moment you hand-edit config.yaml to chase a stubborn CDN, you risk breaking something unrelated because routing is ordered, not magical.

That fear—“what if I cannot undo this?”—is exactly the search intent behind phrases like Clash profile backup, YAML rollback, and multi-device sync. You want a repeatable workflow: snapshot before experiments, compare what changed, and recover in seconds. Graphic tools sometimes offer export buttons, yet exports alone rarely tell you why Tuesday’s file differs from Wednesday’s. Git version control adds an audit trail without forcing you to learn a new proxy stack.

This article does not replace upstream Mihomo documentation; it gives you an operator-minded pattern tested by anyone who treats routers and laptops alike. If you are still choosing a client build, skim the Clash project overview first so the file paths below map cleanly to the GUI you actually run.

Mental model: three copies of “truth”

Separate three notions before you touch git init. First, authoritative YAML is what you intend the core to load—the merged policy groups, rules, DNS stanza, and tun block you would defend in code review. Second, runtime artifacts are caches, downloaded rule-set binaries, GEOIP databases, and log streams that regrow on their own. Third, GUI bookkeeping can include last-selected nodes, window geometry, or update schedules that do not belong in Git because they fight merges.

Your repository should track the first category aggressively, ignore the second unless you have a reason not to, and treat the third as disposable. Many “my laptop synced but my mini PC diverged” reports come from committing machine-local paths or selectively copying half of a profile directory. When the rule stack order drifts between hosts, behavior diverges even if both machines share the same subscription.

What belongs in Git for Mihomo-class profiles

Start with anything you personally edit: the root profile that references proxy-groups, nested includes, static domain lists you curate, and small fixtures used by rule-providers with type: file. If you split DNS into dns.yaml or maintain a rules/ directory, add those paths explicitly. Long-form documentation in a short README.md helps future you remember why a bypass exists.

For remote providers you mirror locally after manual review, committing the frozen copy can be wise—especially on metered links—provided you understand you are now responsible for refreshing it. For always-on HTTP providers, you might track only the YAML entry while letting each machine re-fetch payloads. Pick one strategy per provider; mixing “sometimes file, sometimes HTTP” across laptops is how silent drift appears.

Absolutely exclude obvious noise: crash dumps, huge ephemeral caches, editor swap files, and compiled binaries. If a directory grows to multiple gigabytes without carrying intent, it is not source code—it is landfill.

Secrets, subscription URLs, and private repositories

Subscription URLs are credentials. Anyone with the query string can consume your paid quota or worse. If you use a public GitHub repo, scrub tokens before the first push. Safer patterns include: private remotes with two-factor authentication, self-hosted Git, encrypted offline bundles, or splitting “public routing patterns” from “secret endpoints” using include files that never leave your machine.

Some advanced users replace literal URLs with environment variables and wrapper scripts that expand placeholders at launch. Others maintain two files—config.base.yaml checked into Git and config.local.yaml ignored—which the GUI merges manually. Any approach is fine if .gitignore actually covers the local overlay and your backup plan includes those ignored files separately.

Pushing a repo you thought was private but toggled public later has caused real-world subscription leaks. Revisit repository visibility any time you fork, mirror, or run classroom demos with sample YAML.

A minimal Git workflow that survives real edits

Initialize inside a dedicated folder that only holds the pieces you mean to version—not the entire application bundle. Commit after every stable observation: “GEOIP direct domestics works” beats “wip” by miles when you page back through history during an outage. Use branches for speculative work—experiment-dns-split or try-quic-block—and merge only when your three-domain smoke test passes.

Learn two rollback moves cold. To discard uncommitted scratches, reset or stash. To retreat from a bad commit while keeping history linear for other machines, git revert may beat git reset --hard because it records the undo as its own commit. The exact command matters less than the habit: never let a laptop sit for a week with a “small tweak” you never committed, because that is the version you will miss most after disk failure.

If you collaborate with housemates or homelab teammates, agree whether main must always boot cleanly or whether experimental branches may live remotely. Treat merges like deployment windows: pull, diff, reload Clash, and watch logs—not just hope YAML still parses.

YAML rollback playbook for panic moments

When traffic suddenly dies after a paste-heavy evening, pause before nuking subscriptions. Open your last good commit, identify which file moved, and restore either the entire tree or a single path. Many editors ship inline diff views; use them to spot missing commas and mis-indented lists—classic YAML foot-guns that look like routing bugs.

If the client auto-merges remote snippets from a GUI export, re-export after rollback and verify the effective file the core actually reads. Some apps maintain shadow copies under user profiles; verify you edited the canonical path referenced in the log line that prints on startup.

After restoring text, reload conservatively. Switch one subsystem at a time—DNS first, then rules—so log noise maps to a single change. This method pairs naturally with our rule provider ordering tutorial when the regression involves RULE-SET placement.

New PC migration without rebuilding from memory

Device migration should feel boring: install the client, clone your repository, remap paths, refresh subscriptions, done. The non-boring part is path hygiene. Windows usernames, macOS /Users prefixes, and Linux home snapshots all differ; absolute path: entries in provider blocks must be edited or parameterized. Prefer relative paths anchored inside the repo when the core allows it, so git clone lands runnable everywhere.

On the fresh machine, walk this checklist:

  • Core version alignment: Match major Mihomo revisions when you rely on newer keywords; document the version in README.
  • Privileges: TUN or service modes may require elevated setup distinct from your old OS.
  • DNS listeners: Confirm no other resolver grabbed the same port; stale services love port 53 disagreements.
  • Subscription refresh: Pull fresh nodes once, then validate policy-group health before declaring victory.

If you previously relied on OS-level backups (Time Machine, btrfs snapshots), keep them—but treat Git as the portable spine that ignores vendor lock-in.

Multi-device sync patterns that respect rule order

People hear multi-device sync and imagine Dropbox waving a magic wand. Shared folders work only when every host agrees on file locking and you never edit simultaneously. Git remotes are stricter and kinder long-term: push from the laptop where you tuned rules, pull on the router or secondary desktop, resolve textual conflicts explicitly.

When two machines need slightly different LAN bypasses, resist cloning divergence by accident. Maintain a common base plus tiny per-host overlays—each overlay ignored or stored in clearly named branches—so the shared split routing spine stays identical. merges become predictable instead of guess-the-active-file roulette.

For mobile-only clients without comfortable Git ergonomics, export periodically from the phone, commit on a desktop steward, and treat the handset as a consumer of tagged releases rather than a second source of truth.

Lightweight automation without turning your homelab into Jenkins

Hooks can be as simple as a shell alias that copies the GUI-exported YAML into the repo and runs git commit -am with a timestamp. Scheduled git pull on a router is acceptable only when you review diffs; blindly auto-updating production routing while you sleep is how holiday traffic ends up geolocated wrong.

CI pipelines make sense for teams validating YAML syntax or running linters, yet most individuals gain more from disciplined commit messages than from orchestration theatrics. If you do wire CI, keep secrets in the platform’s vault—not in .gitlab-ci.yml variables checked into history.

Caches, GEOIP, and disk churn

Large geodata files and provider downloads deserve their own policy. Some operators prefer each device fetch fresh data; others pin known-good .mmdb artifacts inside the repo using Git LFS. Plain Git without LFS will bloat quickly. A middle path stores a checksum file next to download scripts so each host pulls the same revision without committing binaries at all.

Whatever you choose, document it beside the geoxxxx: stanza so future migration does not require archeology. Logs referencing outdated country codes are often stale GEOIP, not evil rules.

When Git is overkill—and what to use instead

Not everyone wants a VCS. Alternatives include timestamped zip archives on encrypted media, ZFS snapshots, or Apple Time Machine—each offering rollback without diff. They fail the moment you need line-level insight or coordinated multi-device sync, but they beat nothing.

If you refuse every technical tool, at minimum keep two copies: yesterday’s known-good export and today’s experiment. Rotate them consciously; “I will copy later” is how laptops die on pavement with a monolithic unsaved draft.

Tag releases the way firmware teams do: v2026.05.03-stable before long trips or presentations. Rolling back becomes a one-liner, and your family stops accusing Clash of mood swings.

Frequently asked questions

Can I host this on a bare Git remote with no GUI?

Yes. Many homelab operators push to Gitea or Gitolite instances with zero web UI beyond bare Git. Just ensure TLS, backups of the remote itself, and client-side hooks that remind you to pull before editing.

What if two machines create merge conflicts in YAML?

Open the conflict markers, decide which rule ordering is authoritative, and never blindly accept both halves—duplicate keys and doubled rules: entries are worse than picking a side. When in doubt, branch off, test locally, merge only after latency checks pass.

Does upgrading Mihomo invalidate my Git history?

History stays valid text; the running core may ignore or reinterpret keywords. Track the Mihomo version in README per commit when you rely on bleeding-edge features, and read our Mihomo upgrade guide before jumping major releases.

Version control as insurance for serious routing work

Traditional “set and forget” proxy utilities optimize for hiding complexity, which sounds pleasant until you need to recover yesterday’s working split rules on a new laptop under time pressure. Many of those products keep policy opaque, discourage plaintext inspection, and offer no sane story for YAML rollback beyond reinstalling from scratch. You trade away fine control for a shiny toggle—and the moment a cloud dashboard misroutes a single API host, you are stuck waiting on someone else’s changelog.

Clash ecosystems invert that trade-off: your policy lives in readable text, pairs naturally with Git version control, and scales from a student laptop to a router running Mihomo without rewriting fundamentals. When paired with deliberate backups and clear ignore rules, you get a Clash profile backup workflow that survives adventurous tuning, honest mistakes, and the inevitable device migration to faster hardware.

To align client downloads with the practices above before you refactor DNS or rule providers, use this site’s client download page for curated builds.

→ Download Clash free and pair it with the Git workflow from this guide

Go to download page for Clash clients