git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Questions/investigations on git-subtree and tags

From
Paul Campbell <pcampbell@kemitix.net>
Date
Mar 7, 2013, 11:00 UTC
Message-ID
<CALeLG_=YQDrgMfOoR_GyNRexWxDqQGhFubmaYwM6pqXJuLnO6A@mail.gmail.com>
In-Reply-To
<822188477.192374.1362651959144.JavaMail.root@openwide.fr>
On Thu, Mar 7, 2013 at 10:25 AM, Jeremy Rosen <jeremy.rosen@openwide.fr> wrote:
Show 49 quoted lines
> Hello everybody
>
>
> I am trying to use git-subtree to follow a subproject but I have a couple of problems and I am not sure if I am doing something wrong
>
> Basically I am trying to use a tag on the subproject as my "base" for the subproject but subtree doesn't seem to handle that properly
>
>
> my first attempt was to simply do
>
> "git subtree add --squash git://git.buildroot.net/buildroot 2013.02"
>
> but subtree refused, telling me that the SHA of the tag is not a valid commit.
> Ok it makes sense, though I think this is a very valid use-case...
>
> so I tried
>
> "git subtree add git://git.buildroot.net/buildroot 2013.02^{commit}"
>
> which was refused because git fetch can't parse the ^{commit} marker.
> Again it makes sense, but I really want to start from that tag.
>
>
> so I tried
>
> "git fetch git://git.buildroot.net/buildroot 2013.02"
> "git subtree add --squash FETCH_HEAD"
>
> which worked. Ok at that point I am slightly abusing git subtree, but it seems a valid usage
>
> except that this last attempt causes serious problems when trying to split out the tree again
>
> the call to "git commit-tree" within "git subtree split" complains that the SHA of the parent
> is not a valid commit SHA. Which is true, it's the SHA of the tag.
>
>
> At this point I am not sure if I am abusing subtree, if I have a legitimate but unimplemented use-case and how to
> fix/implement it.
>
> the squash-commit message only contains the SHA of the tag, should it contain the SHA of the commit ?
>
> "subtree split" can only handle commit SHA, should it somehow follow tag SHA too ? how ?
>
> this is probably a trivial fix for someone with good knowledge of git-subtree but i'm not there yet, so any hint would be welcomed
>
>     Regards
>
>     Jérémy Rosen
>
Hi Jérémy,
Git subtree ignores tags from the remote repo.

To follow a project in a subdirectory I would use git-subtree add selecting a branch, not a tag, from the other repo. Then use git-subtree pull to keep yourself updated.

e.g.
To add:
git subtree add --prefix=$subdir $repo $branch
Then to update:
git subtree pull --prefix=$subdir $repo $branch

If you make any changes on the branch and wanted to push them back you could do that with:

git subtree pull --prefix=$subdir $repo2 $branch2

$repo2 and $branch2 would be different from $repo and $branch if you wanted to push to your own fork before submitting a pull request.

-- 
Paul [W] Campbell
Previous: Jeremy RosenNext: Jeremy Rosen
Message 2 of 14 in “Questions/investigations on git-subtree and tags”
  1. Jeremy RosenMar 7, 2013
  2. Paul CampbellMar 7, 2013
  3. Jeremy RosenMar 7, 2013
  4. Paul CampbellMar 7, 2013
  5. Jeremy RosenMar 7, 2013
  6. Paul CampbellMar 7, 2013
  7. Jeremy RosenMar 7, 2013
  8. Paul CampbellMar 7, 2013
  9. Jeremy RosenMar 7, 2013
  10. Jeremy RosenMar 8, 2013
  11. Junio C HamanoMar 8, 2013
  12. Jeremy RosenMar 8, 2013
  13. Jeremy RosenMar 12, 2013
  14. Paul CampbellMar 12, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.