{"thread":{"id":"66034","subject":"[Feature] linked files ��� one source, multiple paths, always identical","startedAt":"2026-07-19T02:46:20Z","lastAt":"2026-07-19T02:46:20Z","messageCount":1,"participants":["sporteka2@disroot.org"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"548617","messageId":"6b78724639d248e0fa9089035b1ff2fb.sporteka2@disroot.org","threadId":"66034","inReplyTo":null,"subject":"[Feature] linked files ��� one source, multiple paths, always identical","fromName":"","fromEmail":"sporteka2@disroot.org","sentAt":"2026-07-19T02:46:09Z","receivedAt":"2026-07-19T02:46:20Z","isPatch":false,"body":"Hi all,\n\nI would like to propose a 'linked files' mechanism for Git: a file can be\ndeclared to mirror another file in the same repository, so the two are\nalways byte-identical. The tooling would enforce identity and keep the\ncopies in sync automatically — no manual copy, no symlink, no commit hook.\n\n== Motivation ==\n\nMany projects need the same source file available from multiple paths:\n\n- a library core reused by an example folder\n  (examples/demo/core.js must equal the root core.js);\n- a shared header copied into submodules;\n- documentation snippets embedded in several places.\n\nToday the only ways to keep them identical are:\n\n- Copy — drifts whenever one side is edited;\n- Symlink — breaks on some archive downloads and cross-filesystem;\n- Hardlink — lost by every git checkout / git reset;\n- Commit hook — a workaround, not a platform guarantee, and runs only\n  at commit time.\n\nNone of these guarantees that the files are identical at any moment,\nwhich is what a maintainer actually wants.\n\n== Proposed mechanism ==\n\nAdd a declarative file (e.g. .gitlinks, similar to .gitignore) mapping\na linked path to its source:\n\n  .gitlinks\n  # linked path            source path\n  examples/demo/core.js   core.js\n\nThe tooling would then:\n\n- On commit — reject the commit if a linked file differs from its source\n  (or auto-overwrite it from the source);\n- On checkout / clone — materialise the linked file from the source\n  (hardlink when the filesystem allows, otherwise an identical copy);\n- On archive / ZIP download — keep the link so the downloaded tree\n  stays correct;\n- On edit — editing either path updates both, so divergence is\n  impossible.\n\n== Why this belongs at the tooling level ==\n\nGit already stores content-addressed blobs, so two identical files share\none blob internally. The missing piece is a working-tree guarantee that\nthe paths stay identical.\n\n== Concrete first step (smaller scope) ==\n\nEven without full 'linked files', a valuable first deliverable would be:\ngit archive should preserve hardlinks between identical files, the way it\nalready preserves symlinks. That alone would let a maintainer hardlink a\nfile locally and have the archive keep the two entries pointing at one\nobject.\n\n== Alternatives considered ==\n\n- Submodules / subtrees — heavier, separate history or full copy, not\n  'same file'.\n- Symlinks — already preserved by git archive, but break on some download\n  tools and cross-filesystem.\n- Commit hooks — work only at commit time, easy to forget, not enforced.\n\nI would appreciate feedback on this proposal.\n\nThanks,\nsporteka\n\n"}]}