Git development
 help / color / mirror / Atom feed
From: "Evan Haque via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Evan Haque <evanhaque1@gmail.com>
Subject: [PATCH 0/5] git son: add command to create independent child repositories
Date: Tue, 26 May 2026 16:47:26 +0000	[thread overview]
Message-ID: <pull.2122.git.1779814052.gitgitgadget@gmail.com> (raw)


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

             reply	other threads:[~2026-05-26 16:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-26 16:47 Evan Haque via GitGitGadget [this message]
2026-05-26 16:47 ` [PATCH 1/5] git-son: add command to create independent child repositories Evan Haque via GitGitGadget
2026-05-26 16:47 ` [PATCH 2/5] git-son: register in Makefile and meson build system Evan Haque via GitGitGadget
2026-05-26 16:47 ` [PATCH 3/5] git-son: add to command list as mainporcelain Evan Haque via GitGitGadget
2026-05-26 16:47 ` [PATCH 4/5] git-son: add documentation Evan Haque via GitGitGadget
2026-05-26 16:47 ` [PATCH 5/5] git-son: add tests Evan Haque via GitGitGadget
2026-05-26 21:27 ` [PATCH 0/5] git son: add command to create independent child repositories Ben Knoble

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.2122.git.1779814052.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=evanhaque1@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox