git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Elijah Newren <newren@gmail.com>
To: Loic Fouray <loic@yeplaa.net>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Git subtree command sustainability
Date: Tue, 23 Nov 2021 11:36:59 -0800	[thread overview]
Message-ID: <CABPp-BF8_E+=8+5UnztM4wYML__E4uC=z5nPVAd+AYVH59Bvqg@mail.gmail.com> (raw)
In-Reply-To: <5D6F04AA-1CE6-423D-B097-58C0F429C9CA@yeplaa.net>

On Tue, Nov 23, 2021 at 11:13 AM Loic Fouray <loic@yeplaa.net> wrote:
>
> Hi,
>
> I want use the git subtree split command on a new repo for splitting, extracting only a directory with its commits related from an upstream repo. It works !
> But I would like to know if the subtree split command is sustainable or if you advise to use other tools (as git-filter-repo for exemple)?
>
> Thanks for your help
> Loïc

Extracting a directory and its commits is a fairly simple kind of
rewrite.  If that's all you need, both tools can do it.  If
git-subtree works for you, that's great, and you don't need to switch
to a different tool.

If you're trying to do something a bit more complex, here are reasons
you might want to use one tool or the other:

- When rewriting history, commit IDs change.  git filter-repo will
rewrite commit messages to update references to (possibly abbreviated)
commit IDs to use the new commit IDs.  As far as I know, it's the only
history rewriting tool that does that; so if that's important to you,
using filter-repo may be beneficial.  But not all projects are
concerned with this; some repositories just don't have commit messages
that reference other commits.

- git-filter-repo allows much more complex rewrites (e.g. replacing
text in files while you are at it, stripping large blobs, using
mailmap to permanently change names, generic path manipulation,
inserting a commit, etc.), so if you also need to make other changes,
filter-repo is the tool you want.  git-subtree offers no other kind of
rewrite.

- git-filter-repo makes no effort to allow simultaneously working with
both the original and rewritten histories.  That kind of thing does
not mesh well with a generic history rewriting tool; you have to have
very specific types of rewrites to allow history to be reversible so
you can take information back to the original repo (in addition to
needing to track extra metadata).  However, git-subtree was written
precisely with a limited history rewrite in mind where this is
possible and provides tooling to assist you in working with both
histories and porting changes between the two.  If that's something
you want to do, git-subtree is the better tool for you.

- If you run into a scale where git-subtree doesn't work, but you do
want the simultaneous working with old-and-new histories abilities,
you may want to look into https://github.com/josh-project/josh.


Hope that helps,
Elijah

      reply	other threads:[~2021-11-23 19:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23 15:10 Git subtree command sustainability Loic Fouray
2021-11-23 19:36 ` Elijah Newren [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to='CABPp-BF8_E+=8+5UnztM4wYML__E4uC=z5nPVAd+AYVH59Bvqg@mail.gmail.com' \
    --to=newren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=loic@yeplaa.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).