- Add ADR 004 documenting existing repository linking architecture - Rewrite README with impersonal tone, removing workstation/laptop coupling - Document existing repository workflow and updated CLI options
2.8 KiB
2.8 KiB
ADR 004: Existing Repository Linking and Auto-Detection
Status
Accepted (2026-10-10)
Context
Initial iterations of new-repo assumed a purely greenfield workflow:
- Create a remote repository on Gitea with
auto_init=True(generating an initial commit with a README and license). - Create an empty backup repository on GitHub.
- Register Gitea push mirroring.
- Clone the newly generated repository into
$PWD/<name>.
However, in daily developer workflows, repositories frequently already exist locally:
- A developer starts prototyping code locally before provisioning remotes.
- An existing standalone repository needs sovereign Gitea hosting and GitHub offsite backup attached.
If executed against an existing local repository:
- Creating the remote on Gitea with
auto_init=Truegenerates a remote initial commit that diverges from local commits, causing git history conflicts (fatal: refusing to merge unrelated histories). - Skipping the local clone step without adding
originor pushing commits leaves the developer with an empty remote and unlinked local working tree.
Decision
We will add first-class existing repository support and auto-detection to new-repo:
- Target & Name Resolution:
- If
nameis omitted or passed as.,new-repouses the current working directory name and targets$PWD. - If
namematches the current directory or points to an existing directory containing.git, the utility switches into Existing Repository Mode.
- If
- Empty Remote Creation:
- When linking an existing repository, Gitea is provisioned with
auto_init=Falseand no license generation. Both Gitea and GitHub remotes are initialized completely empty.
- When linking an existing repository, Gitea is provisioned with
- Local Remote Wiring & Push:
new-repoconfiguresoriginon the local repository pointing togit@<gitea-host>:<user>/<repo>.git.- The tool detects the current active branch (defaulting to
main) and pushes with upstream tracking (git push -u origin <branch>). - Server-side, Gitea automatically synchronizes all pushed commits to GitHub via the registered push mirror.
Consequences
Good
- Unified Command:
new-repohandles both greenfield project generation and remote attachment for existing local code with the same interface. - Commit Lineage Preserved: Eliminates divergent history conflicts by ensuring remote forges remain empty until the local branch is pushed.
- Developer Ergonomics: Running
new-repoinside any existing git project immediately binds it to sovereign dual-forge infrastructure in one step.
Bad
- The script now requires read/write access to local
.gitconfiguration and executes localgit remoteandgit pushcommands.
Neutral
- If
originalready exists,new-repoupdates the remote URL to the primary Gitea instance.