Files
docs/canons/template-sync-strategy/setup/clean-repository.md
S.Gromov 1a14df9366 feat: добавить документацию Template Sync Strategy
- добавлены каноны и VitePress-сайт стратегии обновления шаблонов

- подключена карточка документации на главной странице

- добавлены сборочные скрипты, Caddy-маршрут и Docker-сборка

- добавлена git-иконка для карточки и сгенерированы публичные артефакты
2026-05-13 23:23:31 +03:00

120 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Новый проект от шаблона
description: Старт нового приложения от шаблонного репозитория с правильной историей веток.
---
# Новый проект от шаблона
Этот сценарий подходит, когда репозиторий приложения ещё пустой или его можно безопасно пересоздать от шаблона.
Целевая модель:
```text
templates/master -> template -> sync/* -> master
```
## Условия
Есть два репозитория:
```text
template repo = репозиторий шаблона
app repo = репозиторий приложения
```
В обоих репозиториях основная ветка называется `master`.
## Подготовить шаблон
В репозитории шаблона:
```bash
cd /path/to/template-repo
git switch master
```
Если это пустой репозиторий, добавьте первый файл и запушьте `master`:
```bash
printf "# Template Repository\n\nBase template version: v1\n" > README.md
git add README.md
git commit -m "docs: добавить базовый шаблон"
git push -u origin master
```
## Подключить шаблон в приложении
В репозитории приложения:
```bash
cd /path/to/app-repo
git remote add templates <template-repo-url>
git fetch templates
```
Создайте ветку `template` от шаблона:
```bash
git switch -c template templates/master
git push -u origin template
```
Создайте ветку приложения `master` от `template`:
```bash
git switch -c master template
```
Добавьте слой приложения:
```bash
mkdir -p app
printf "Application code v1\n" > app/app.txt
git add app/app.txt
git commit -m "feat: добавить слой приложения"
git push -u origin master
```
После этого история выглядит так:
```text
template: T1
master: T1---A1
```
Где `T1` — коммит шаблона, а `A1` — коммит приложения.
## Настроить pull и push для template
Можно сделать так, чтобы на ветке `template`:
```text
git pull тянул из templates/master
git push пушил в origin/template
```
Команды:
```bash
git config branch.template.remote templates
git config branch.template.merge refs/heads/master
git config branch.template.pushRemote origin
```
Дополнительно можно запретить случайный push в репозиторий шаблона:
```bash
git remote set-url --push templates DISABLED
```
## Дальше
После первичной настройки постоянные ветки такие:
```text
template = чистый шаблон
master = приложение
```
Обновления шаблона выполняются через временные ветки `sync/*` по инструкции [Обычное обновление шаблона](../workflows/update-template.md).