我有一个为我的应用程序编写的库,但现在想在我公司要编写的所有应用程序中使用它。该应用程序和库都位于 git 存储库(存储库 A)中,其中包含我非常想保留的历史记录。该库位于它自己的子文件夹中。
我还有第二个存储库(存储库 B),其中包含一些其他共享代码 - 这在我们编写的应用程序中用作 git 子模块。
我想从存储库 A 中获取库子文件夹并将其放入存储库 B 中而不丢失其历史记录。
我查看了 git-bundle ,但似乎无法指定文件,只能指定分支。
我还考虑过复制存储库并删除我不需要的文件(像这样< /a>),但库文件以不同的名称和不同的文件夹开始,所以我不确定它是如何工作的。
有谁知道实现此目的的最佳方法吗?
I have a library that I wrote for my app but now want to use it in all apps my company is going to write. The app and library both live in a git repository (repository A) with history that I really would like to preserve. The library sits in it's own subfolder.
I also have a second repository (repository B) that contains some other shared code - this is used as a git-submodule in apps that we write.
I would like to take the libraries subfolder from repository A and place it into repository B without losing it's history.
I've looked at git-bundle
but don't seem to be able to specify files, only branches.
I've also looked at copying the repository and removing the files I don't want (like this) but the libraries files started out with different names and in different folders so I'm just not sure how that would work.
Does anyone have any ideas of the best way that this could be done?
发布评论
评论(2)
请注意,使用 Git 2.36(2022 年第二季度,十一年后),git bundle 本身将支持您的用例:捆绑文件格式得到扩展,以允许部分捆绑,并按照您在制作部分/惰性克隆时给出的类似标准进行过滤。
请参阅 提交 86fdd94、提交 4f39eb0, 提交f18b512,提交 c4ea513,提交 105c6f1, 提交 f0d2f84,提交 3e0370a,提交09d4a79,提交 7940941,提交 ffaa137 , 提交 4a4c3f9, 提交 1f52cdf(2022 年 3 月 9 日),作者:Derrick Stolee (
derrickstolee
)。请参阅 提交 4f33a63(2022 年 3 月 9 日),作者:Ævar Arnfjörð Bjarmason (
avar
)。(由 Junio C Hamano --
gitster
-- 合并于 提交 7391ecd,2022 年 3 月 21 日)并且,仍然使用 Git 2.36(2022 年第 2 季度):
请参阅提交 5cb2827(2022 年 3 月 28 日) )作者:Ævar Arnfjörð Bjarmason (
avar
)。请参阅 提交 8ba221e、提交 017303e, 提交831ee25,提交80f6de4,提交 cc91044(2022 年 3 月 22 日),作者 Derrick Stolee (
derrickstolee
)。(由 Junio C Hamano --
gitster
-- 合并于 提交 3928e90,2022 年 4 月 4 日)git bundle
现在包含在其 手册页:Note that, with Git 2.36 (Q2 2022, eleven years later), git bundle itself will support your use case: the bundle file format gets extended to allow a partial bundle, filtered by similar criteria you would give when making a partial/lazy clone.
See commit 86fdd94, commit 4f39eb0, commit f18b512, commit c4ea513, commit 105c6f1, commit f0d2f84, commit 3e0370a, commit 09d4a79, commit 7940941, commit ffaa137, commit 4a4c3f9, commit 1f52cdf (09 Mar 2022) by Derrick Stolee (
derrickstolee
).See commit 4f33a63 (09 Mar 2022) by Ævar Arnfjörð Bjarmason (
avar
).(Merged by Junio C Hamano --
gitster
-- in commit 7391ecd, 21 Mar 2022)And, still with Git 2.36 (Q2 2022):
See commit 5cb2827 (28 Mar 2022) by Ævar Arnfjörð Bjarmason (
avar
).See commit 8ba221e, commit 017303e, commit 831ee25, commit 80f6de4, commit cc91044 (22 Mar 2022) by Derrick Stolee (
derrickstolee
).(Merged by Junio C Hamano --
gitster
-- in commit 3928e90, 04 Apr 2022)git bundle
now includes in its man page:您正在寻找
git filter-branch
。请参阅此问题和答案(请务必注意标记为“编辑”的附加部分', 也)。You're looking for
git filter-branch
. See this question and answer (be sure to note the additional section marked 'edit', too).