git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Manuel Reimer <mail+git@m-reimer.de>
To: git@vger.kernel.org
Subject: Re: How to properly use git-subtree (and prevent it from adding merge commits)?
Date: Fri, 27 May 2022 19:55:42 +0200	[thread overview]
Message-ID: <393b5026-e861-b5b1-a474-5d56464dba91@m-reimer.de> (raw)
In-Reply-To: <3DEED6A1-6344-472C-9E03-39ADF3076B2D@m-reimer.de>

Hello,

I tried the "subtree push" and now the merge commit did not get pushed. 
I'm sure it was when I still had my old subtree repo before rebuilding.

So probably the reason why git went crazy was because the initial 
subtree repo was created based on one of my projects repositories by 
filtering the commits down to just the files I wanted to extract.

So probably some internal references matched when pushing. I recreated 
this subtree repo from scratch now and imported all relevant commits 
using "git am". I hope this guarantees that I don't get unwanted 
references from the source repository.

What will happen if I get a pull request which covers both, project 
files and subtree files and then "subtree push" the changes? Will this 
cause the merge commit to get pushed to my subtree repo?

Thanks

Manuel

On 27.05.22 16:54, Manuel Reimer wrote:
> Hello,
> 
> maybe it's a bug in later GIT versions (2.36.1 here) but I kind of struggle to get git-subtree to work properly.
> 
> I even recreated the repo, I use for the subtree, from scratch to get sure there are no backreferences to the repo I've added the subtree to.
> 
> This is the repo, I want to have as "subtree" in other repos:
> 
> https://github.com/M-Reimer/webext-utils
> 
> I now pulled this into two projects as subtree using the command
> 
> https://github.com/M-Reimer/undoclosetab
> https://github.com/M-Reimer/savescreenshot
> 
> For both projects I used the command:
> 
> git subtree add --prefix utils git@github.com:M-Reimer/webext-utils.git master
> 
> In the first project (undoclosetab) I then added a new commit ("Add managed preference support") and pushed this back to the "subtree repo" using:
> 
> git subtree push --prefix utils git@github.com:M-Reimer/webext-utils.git master
> 
> If I now try to pull this into my second project (savescreenshot), then git creates a merge commit for no reason.
> 
> 
> git subtree pull --prefix utils "git@github.com:M-Reimer/webext-utils.git" master
> remote: Enumerating objects: 5, done.
> remote: Counting objects: 100% (5/5), done.
> remote: Compressing objects: 100% (2/2), done.
> Unpacking objects: 100% (3/3), 1.94 KiB | 497.00 KiB/s, done.
> remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
>  From github.com:M-Reimer/webext-utils
>   * branch            master     -> FETCH_HEAD
> Merge made by the 'ort' strategy.
>   utils/storage.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 56 insertions(+), 1 deletion(-)
> 
> 
> Why does this happen? As soon as I have this merge commit a following "subtree push" also pushes this merge commit to the subtree repo and also pushes tags that are not relevant there.
> 
> I'm out of ideas now.
> 
> What I want to do: I want to be able to develop on modules, I have in the "subtree repo" in every project I want and then push the changes to the subtree repo for pulling into the other projects. That's why I don't want to use "squash" as I don't want to do development only in the subtree repo directly.
> 
> Thanks for any hints.
> 
> Manuel


      reply	other threads:[~2022-05-27 17:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27 14:54 How to properly use git-subtree (and prevent it from adding merge commits)? Manuel Reimer
2022-05-27 17:55 ` Manuel Reimer [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=393b5026-e861-b5b1-a474-5d56464dba91@m-reimer.de \
    --to=mail+git@m-reimer.de \
    --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.
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).