From: Mikhail Efremov <sem@altlinux.org>
To: devel-newbies@lists.altlinux.org
Subject: Re: [newbies] git pull into subdirectory
Date: Wed, 12 Nov 2025 20:46:16 +0300
Message-ID: <20251112204616.177a5a8b@sem.office.basealt.ru> (raw)
In-Reply-To: <20251112195858.32eebe09@legato>
On Wed, 12 Nov 2025 19:58:58 +0300 Paul Wolneykien wrote:
> В Tue, 11 Nov 2025 21:36:19 +0300
> Alexander Lubyagin <lubyagin@yandex.ru> пишет:
>
> > Добрый день.
> >
> > Возник такой вопрос.
> >
> > Во многих репозиториях Альта принят принцип - хранить исходники в
> > подкаталоге %name/%name/
> >
> > Как оформить первый коммит, чтобы из удалённого репозитория свежие
> > коммиты подтягивались сразу в подкаталог по git fetch?
>
> В последнее время использую команду git subtree.
>
> Ранее же делал через -Xsubtree, то есть:
>
> git pull/merge --allow-unrelated-histories -Xsubtree=subdir/ ...
>
> После первого раза git потом сам туда складывает. Однако, чтобы любой
> из данных способов сработал, необходимо, чтобы subdir/ уже существовал
> _внутри git_. Для этого нужно сделать, например, вот так:
>
> mkdir subdir
> touch subdir/.gitignore
> git add subdir/.gitignore
> git commit -m "Prepare subdir for git://project.path/repo.git"
>
> И дальше уже git subtree или git pull --allow.. -Xsubtree=...
У меня почти все репо с апстримными исходниками в subtree, но я просто
готовлю subtree по инструкции с
https://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html
Никаких "touch subdir/.gitignore" при этом не требуется.
Потом мержу апстрим как git merge -X subtree=<subdir> <тэг>
Единственная проблема, которую я встречал при такой схеме: если в
дереве исходников апстрима есть каталог, имя которого совпадает с
именем subdir (а обычно это %name), то git'у может снести крышу при
мерже. В этом случае я просто переименовываю subdir в %{name}-src.
Впрочем, давно уже такого не видел, может git уже научился справляться
с этим.
--
WBR, Mikhail Efremov
prev parent reply other threads:[~2025-11-12 17:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-11 18:36 Alexander Lubyagin
2025-11-12 5:25 ` Anton Farygin
2025-11-12 15:07 ` shad
2025-11-12 17:13 ` Anton Farygin
2025-11-12 7:49 ` Alexander Lubyagin
2025-11-12 16:58 ` Paul Wolneykien
2025-11-12 17:46 ` Mikhail Efremov [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251112204616.177a5a8b@sem.office.basealt.ru \
--to=sem@altlinux.org \
--cc=devel-newbies@lists.altlinux.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
devel@ where you _can_ ask
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel-newbies/0 devel-newbies/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel-newbies devel-newbies/ http://lore.altlinux.org/devel-newbies \
devel-newbies@lists.altlinux.org devel-newbies@lists.altlinux.ru devel-newbies@lists.altlinux.com
public-inbox-index devel-newbies
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel-newbies
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git