Subject: [PATCH 0/5] git son: add command to create independent child repositories

From: "Evan Haque via GitGitGadget" <[email-masked]>
Date: Tue, 26 May 2026 16:47:26 +0000

Motivation
==========

When spinning off a new project that is related to an existing repository,
there is no built-in way to create a child repository that maintains a link
back to its parent without the tight coupling of submodules. Submodules pin
the child to a specific commit and require the parent to track the child in
its index, which is too heavyweight when the child is meant to be fully
independent.

The typical workflow today is manual: git init, git remote add, update
.gitignore — three steps that are easy to forget or get wrong. git son
automates this and establishes a lightweight convention for the parent-child
relationship: a remote named parent in the child, and nothing in the parent
except an ignore rule.

Summary
=======

This series introduces git son, a new porcelain command that creates an
independent child repository inside the current working tree. Unlike a
submodule, the child is not tracked by the parent; instead, its subdirectory
is added to the parent's .gitignore. The child is configured at creation
time with a remote named parent pointing back to the parent repository's
origin URL (or local path if no origin exists), making the lineage explicit
and recoverable via standard Git commands.

Changes
=======

 * git-son.sh: new shell script implementing the command, supporting
   --inherit to fetch parent history at creation time and --branch <branch>
   (requires --inherit) to check out a specific parent branch
 * git-son registered in command-list.txt as mainporcelain
 * git-son.sh added to SCRIPT_SH in Makefile and to scripts_sh in
   meson.build
 * Documentation/git-son.adoc: new man page covering synopsis, option
   descriptions, and worked examples
 * Documentation/meson.build: git-son.adoc added to the manpage build list
 * t/t5151-son.sh: new test script covering basic creation, parent remote
   configuration, .gitignore update, idempotency failure, flag validation,
   and --inherit with a bare remote

Details
=======

The key design property is independence: the child is a fully self-contained
repository with no entry in the parent's index. The parent remote is the
only artifact linking the two, which means git fetch parent and git log
parent/<branch> work as expected from within the child without any special
tooling.

The --branch flag is intentionally restricted to --inherit mode. Without
fetching, there is no remote-tracking branch to check out from, so accepting
--branch alone would be misleading; the command dies with a clear diagnostic
in that case.

When no origin URL is available in the parent, the parent remote is set to
the parent's absolute local path. This covers the common case of
repositories that have never been pushed to a remote.

Testing
=======

t/t5151-son.sh covers the following scenarios:

 * Basic child repository creation (directory exists, .git present)
 * parent remote is correctly recorded in the child
 * Child directory is appended to the parent's .gitignore
 * Child starts with exactly one initial commit when --inherit is not used
 * Command fails without leaving a directory when the target already exists
 * --branch without --inherit is rejected before any filesystem changes
 * --inherit fetches parent history and the remote-tracking branch is
   reachable in the child

Evan Haque (5):
  git-son: add command to create independent child repositories
  git-son: register in Makefile and meson build system
  git-son: add to command list as mainporcelain
  git-son: add documentation
  git-son: add tests

 .gitignore                 |  1 +
 Documentation/git-son.adoc | 64 +++++++++++++++++++++++++
 Documentation/meson.build  |  1 +
 Makefile                   |  1 +
 command-list.txt           |  1 +
 git-son.sh                 | 97 ++++++++++++++++++++++++++++++++++++++
 meson.build                |  1 +
 t/meson.build              |  1 +
 t/t5151-son.sh             | 63 +++++++++++++++++++++++++
 9 files changed, 230 insertions(+)
 create mode 100644 Documentation/git-son.adoc
 create mode 100755 git-son.sh
 create mode 100755 t/t5151-son.sh

base-commit: aec3f587505a472db67e9462d0702e7d463a449d
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2122%2FEvandabest%2Fgit-son-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2122/Evandabest/git-son-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2122
-- 
gitgitgadget